Skip to content

Commit c7d93ff

Browse files
committed
[FAB-3636] Check the error, associating id to cert
Currently in the communication gossip module while creating a new instance in the method NewCommInstanceWithServer there is an associating between peer pkiid and cert, however no error check has been made, hence ignoring potential problem. Same problem also exists in gossip_service.go. This commit adds error check, reporting to the log and panic, since this is an indication of peer bad condition. Change-Id: Id1da501581b5a9e96b08343b80133286b3ade0d0 Signed-off-by: Artem Barger <[email protected]>
1 parent 2a15510 commit c7d93ff

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

gossip/comm/comm_impl.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ func NewCommInstanceWithServer(port int, idMapper identity.Mapper, peerIdentity
9999
subscriptions: make([]chan proto.ReceivedMessage, 0),
100100
}
101101
commInst.connStore = newConnStore(commInst, commInst.logger)
102-
commInst.idMapper.Put(idMapper.GetPKIidOfCert(peerIdentity), peerIdentity)
102+
if err := commInst.idMapper.Put(idMapper.GetPKIidOfCert(peerIdentity), peerIdentity); err != nil {
103+
commInst.logger.Panic("Failed associating self PKIID to cert:", err)
104+
}
103105

104106
if port > 0 {
105107
commInst.stopWG.Add(1)

gossip/service/gossip_service.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ func InitGossipServiceCustomDeliveryFactory(peerIdentity []byte, endpoint string
138138
logger.Info("Initialize gossip with endpoint", endpoint, "and bootstrap set", bootPeers)
139139

140140
idMapper := identity.NewIdentityMapper(mcs)
141-
idMapper.Put(mcs.GetPKIidOfCert(peerIdentity), peerIdentity)
141+
if err := idMapper.Put(mcs.GetPKIidOfCert(peerIdentity), peerIdentity); err != nil {
142+
logger.Panic("Failed associating self PKIID to cert:", err)
143+
}
142144

143145
gossip := integration.NewGossipComponent(peerIdentity, endpoint, s, secAdv,
144146
mcs, idMapper, secureDialOpts, bootPeers...)

0 commit comments

Comments
 (0)