Skip to content

Commit

Permalink
[FAB-2499] different OrgID and OrgName in configtx.yaml
Browse files Browse the repository at this point in the history
Previously, in order for gossip to be able to join a channel,
the OrgID (that sets the MSP-ID) and the OrgName in the configtx.yaml
were needed to be the same.

This commit removes this requirement by using the fact that ApplicationOrg
embeds Org and the latter has an MSPID() method.

I tested this by using a configtx.yaml with different OrgName and OrgID.

Change-Id: I6435047fa97b16532491a22490dcde0f151945b0
Signed-off-by: Yacov Manevich <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Apr 17, 2017
1 parent 43c0146 commit ecc1162
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions gossip/service/gossip_service.go
Expand Up @@ -224,13 +224,14 @@ func (g *gossipServiceImpl) configUpdated(config Config) {
return
}
jcm := &joinChannelMessage{seqNum: config.Sequence(), members2AnchorPeers: map[string][]api.AnchorPeer{}}
for orgID, appOrg := range config.Organizations() {
for _, appOrg := range config.Organizations() {
logger.Debug(appOrg.MSPID(), "anchor peers:", appOrg.AnchorPeers())
for _, ap := range appOrg.AnchorPeers() {
anchorPeer := api.AnchorPeer{
Host: ap.Host,
Port: int(ap.Port),
}
jcm.members2AnchorPeers[orgID] = append(jcm.members2AnchorPeers[orgID], anchorPeer)
jcm.members2AnchorPeers[appOrg.MSPID()] = append(jcm.members2AnchorPeers[appOrg.MSPID()], anchorPeer)
}
}

Expand Down Expand Up @@ -305,8 +306,8 @@ func (g *gossipServiceImpl) onStatusChangeFactory(chainID string, committer bloc

func orgListFromConfig(config Config) []string {
var orgList []string
for orgName := range config.Organizations() {
orgList = append(orgList, orgName)
for _, appOrg := range config.Organizations() {
orgList = append(orgList, appOrg.MSPID())
}
return orgList
}
7 changes: 4 additions & 3 deletions gossip/service/join_test.go
Expand Up @@ -79,14 +79,15 @@ func (*gossipMock) Stop() {
}

type appOrgMock struct {
id string
}

func (*appOrgMock) Name() string {
panic("implement me")
}

func (*appOrgMock) MSPID() string {
panic("implement me")
func (ao *appOrgMock) MSPID() string {
return ao.id
}

func (*appOrgMock) AnchorPeers() []*peer.AnchorPeer {
Expand All @@ -102,7 +103,7 @@ func (*configMock) ChainID() string {

func (*configMock) Organizations() map[string]config.ApplicationOrg {
return map[string]config.ApplicationOrg{
"Org0": &appOrgMock{},
"Org0": &appOrgMock{"Org0"},
}
}

Expand Down

0 comments on commit ecc1162

Please sign in to comment.