Skip to content

Commit ecc1162

Browse files
committed
[FAB-2499] different OrgID and OrgName in configtx.yaml
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 <[email protected]>
1 parent 43c0146 commit ecc1162

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

gossip/service/gossip_service.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,14 @@ func (g *gossipServiceImpl) configUpdated(config Config) {
224224
return
225225
}
226226
jcm := &joinChannelMessage{seqNum: config.Sequence(), members2AnchorPeers: map[string][]api.AnchorPeer{}}
227-
for orgID, appOrg := range config.Organizations() {
227+
for _, appOrg := range config.Organizations() {
228+
logger.Debug(appOrg.MSPID(), "anchor peers:", appOrg.AnchorPeers())
228229
for _, ap := range appOrg.AnchorPeers() {
229230
anchorPeer := api.AnchorPeer{
230231
Host: ap.Host,
231232
Port: int(ap.Port),
232233
}
233-
jcm.members2AnchorPeers[orgID] = append(jcm.members2AnchorPeers[orgID], anchorPeer)
234+
jcm.members2AnchorPeers[appOrg.MSPID()] = append(jcm.members2AnchorPeers[appOrg.MSPID()], anchorPeer)
234235
}
235236
}
236237

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

306307
func orgListFromConfig(config Config) []string {
307308
var orgList []string
308-
for orgName := range config.Organizations() {
309-
orgList = append(orgList, orgName)
309+
for _, appOrg := range config.Organizations() {
310+
orgList = append(orgList, appOrg.MSPID())
310311
}
311312
return orgList
312313
}

gossip/service/join_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ func (*gossipMock) Stop() {
7979
}
8080

8181
type appOrgMock struct {
82+
id string
8283
}
8384

8485
func (*appOrgMock) Name() string {
8586
panic("implement me")
8687
}
8788

88-
func (*appOrgMock) MSPID() string {
89-
panic("implement me")
89+
func (ao *appOrgMock) MSPID() string {
90+
return ao.id
9091
}
9192

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

103104
func (*configMock) Organizations() map[string]config.ApplicationOrg {
104105
return map[string]config.ApplicationOrg{
105-
"Org0": &appOrgMock{},
106+
"Org0": &appOrgMock{"Org0"},
106107
}
107108
}
108109

0 commit comments

Comments
 (0)