From f0290e4c9c886ad943b232750d69d095210fb668 Mon Sep 17 00:00:00 2001 From: Simon Stone Date: Mon, 21 Sep 2020 14:15:11 +0100 Subject: [PATCH] Specify which identities should be hidden (resolves #53) (#54) Signed-off-by: Simon Stone --- internal/pkg/console/console.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/pkg/console/console.go b/internal/pkg/console/console.go index 48bca8f..102b34c 100644 --- a/internal/pkg/console/console.go +++ b/internal/pkg/console/console.go @@ -64,6 +64,7 @@ type jsonIdentity struct { CA []byte `json:"ca"` MSPID string `json:"msp_id"` Wallet string `json:"wallet"` + Hide bool `json:"hide"` } type components map[string]interface{} @@ -83,18 +84,21 @@ type Console struct { func New(organizations []*organization.Organization, orderer *orderer.Orderer, peers []*peer.Peer, cas []*ca.CA, port int32, curl string) (*Console, error) { staticComponents := components{} for _, organization := range organizations { - for _, orgIdentity := range organization.GetIdentities() { - id := strings.ToLower(orgIdentity.Name()) + orgHide := organization == orderer.Organization() + for _, identity := range organization.GetIdentities() { + identityHide := orgHide || identity != organization.Admin() + id := strings.ToLower(identity.Name()) id = strings.ReplaceAll(id, " ", "") staticComponents[id] = &jsonIdentity{ ID: id, - DisplayName: orgIdentity.Name(), + DisplayName: identity.Name(), Type: "identity", - Certificate: orgIdentity.Certificate().Bytes(), - PrivateKey: orgIdentity.PrivateKey().Bytes(), - CA: orgIdentity.CA().Bytes(), + Certificate: identity.Certificate().Bytes(), + PrivateKey: identity.PrivateKey().Bytes(), + CA: identity.CA().Bytes(), MSPID: organization.MSPID(), Wallet: organization.Name(), + Hide: identityHide, } } }