Skip to content

Commit c220290

Browse files
committed
[FAB-3349] Keep gossip proto fields be with underscores
The fields in proto message definitions should not be CamelCase but should be with underscores. Therefore we should change the proto field channelMAC to channel_mac And also secretEnvelope to secret_envelope Change-Id: I8c99ebd0d06d5a87024888e1bf6664c7131be961 Signed-off-by: Yacov Manevich <[email protected]>
1 parent 5b80e47 commit c220290

File tree

7 files changed

+122
-121
lines changed

7 files changed

+122
-121
lines changed

gossip/gossip/channel/channel.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,9 @@ func (gc *gossipChannel) handleStateInfSnapshot(m *proto.GossipMessage, sender c
502502
}
503503

504504
expectedMAC := GenerateMAC(si.PkiId, gc.chainID)
505-
if !bytes.Equal(si.ChannelMAC, expectedMAC) {
505+
if !bytes.Equal(si.Channel_MAC, expectedMAC) {
506506
gc.logger.Warning("Channel", chanName, ": StateInfo message", stateInf,
507-
", has an invalid MAC. Expected", expectedMAC, ", got", si.ChannelMAC, ", sent from", sender)
507+
", has an invalid MAC. Expected", expectedMAC, ", got", si.Channel_MAC, ", sent from", sender)
508508
return
509509
}
510510
err = gc.ValidateStateInfoMessage(stateInf)
@@ -589,8 +589,8 @@ func (gc *gossipChannel) verifyMsg(msg proto.ReceivedMessage) bool {
589589
if m.IsStateInfoMsg() {
590590
si := m.GetStateInfo()
591591
expectedMAC := GenerateMAC(si.PkiId, gc.chainID)
592-
if !bytes.Equal(expectedMAC, si.ChannelMAC) {
593-
gc.logger.Warning("Message contains wrong channel MAC(", si.ChannelMAC, "), expected", expectedMAC)
592+
if !bytes.Equal(expectedMAC, si.Channel_MAC) {
593+
gc.logger.Warning("Message contains wrong channel MAC(", si.Channel_MAC, "), expected", expectedMAC)
594594
return false
595595
}
596596
return true
@@ -599,8 +599,8 @@ func (gc *gossipChannel) verifyMsg(msg proto.ReceivedMessage) bool {
599599
if m.IsStateInfoPullRequestMsg() {
600600
sipr := m.GetStateInfoPullReq()
601601
expectedMAC := GenerateMAC(msg.GetConnectionInfo().ID, gc.chainID)
602-
if !bytes.Equal(expectedMAC, sipr.ChannelMAC) {
603-
gc.logger.Warning("Message contains wrong channel MAC(", sipr.ChannelMAC, "), expected", expectedMAC)
602+
if !bytes.Equal(expectedMAC, sipr.Channel_MAC) {
603+
gc.logger.Warning("Message contains wrong channel MAC(", sipr.Channel_MAC, "), expected", expectedMAC)
604604
return false
605605
}
606606
return true
@@ -619,7 +619,7 @@ func (gc *gossipChannel) createStateInfoRequest() *proto.SignedGossipMessage {
619619
Nonce: 0,
620620
Content: &proto.GossipMessage_StateInfoPullReq{
621621
StateInfoPullReq: &proto.StateInfoPullRequest{
622-
ChannelMAC: GenerateMAC(gc.pkiID, gc.chainID),
622+
Channel_MAC: GenerateMAC(gc.pkiID, gc.chainID),
623623
},
624624
},
625625
}).NoopSign()

gossip/gossip/channel/channel_test.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ func TestChannelPeerNotInChannel(t *testing.T) {
542542

543543
// Ensure we don't respond to a StateInfoRequest in the wrong channel from a peer in the right org
544544
req2 := gc.(*gossipChannel).createStateInfoRequest()
545-
req2.GetStateInfoPullReq().ChannelMAC = GenerateMAC(pkiIDInOrg1, common.ChainID("B"))
545+
req2.GetStateInfoPullReq().Channel_MAC = GenerateMAC(pkiIDInOrg1, common.ChainID("B"))
546546
invalidReceivedMsg2 := &receivedMsg{
547547
msg: req2,
548548
PKIID: pkiIDInOrg1,
@@ -897,7 +897,7 @@ func TestChannelStateInfoSnapshot(t *testing.T) {
897897

898898
// Ensure we ignore stateInfo snapshots with StateInfo messages with wrong MACs
899899
sim := createStateInfoMsg(4, pkiIDInOrg1, channelA)
900-
sim.GetStateInfo().ChannelMAC = append(sim.GetStateInfo().ChannelMAC, 1)
900+
sim.GetStateInfo().Channel_MAC = append(sim.GetStateInfo().Channel_MAC, 1)
901901
sim = sim.NoopSign()
902902
gc.HandleMessage(&receivedMsg{PKIID: pkiIDInOrg1, msg: stateInfoSnapshotForChannel(channelA, sim)})
903903
assert.Empty(t, gc.GetPeers())
@@ -918,7 +918,7 @@ func TestChannelStateInfoSnapshot(t *testing.T) {
918918
Tag: proto.GossipMessage_CHAN_OR_ORG,
919919
Content: &proto.GossipMessage_StateInfoPullReq{
920920
StateInfoPullReq: &proto.StateInfoPullRequest{
921-
ChannelMAC: append(GenerateMAC(pkiIDInOrg1, channelA), 1),
921+
Channel_MAC: append(GenerateMAC(pkiIDInOrg1, channelA), 1),
922922
},
923923
},
924924
}).NoopSign(),
@@ -941,7 +941,7 @@ func TestChannelStateInfoSnapshot(t *testing.T) {
941941
Tag: proto.GossipMessage_CHAN_OR_ORG,
942942
Content: &proto.GossipMessage_StateInfoPullReq{
943943
StateInfoPullReq: &proto.StateInfoPullRequest{
944-
ChannelMAC: GenerateMAC(pkiIDInOrg1, channelA),
944+
Channel_MAC: GenerateMAC(pkiIDInOrg1, channelA),
945945
},
946946
},
947947
}).NoopSign(),
@@ -1043,7 +1043,7 @@ func TestInterOrgExternalEndpointDisclosure(t *testing.T) {
10431043
Tag: proto.GossipMessage_CHAN_OR_ORG,
10441044
Content: &proto.GossipMessage_StateInfoPullReq{
10451045
StateInfoPullReq: &proto.StateInfoPullRequest{
1046-
ChannelMAC: GenerateMAC(pkiID3, channelA),
1046+
Channel_MAC: GenerateMAC(pkiID3, channelA),
10471047
},
10481048
},
10491049
}).NoopSign(),
@@ -1074,7 +1074,7 @@ func TestInterOrgExternalEndpointDisclosure(t *testing.T) {
10741074
Tag: proto.GossipMessage_CHAN_OR_ORG,
10751075
Content: &proto.GossipMessage_StateInfoPullReq{
10761076
StateInfoPullReq: &proto.StateInfoPullRequest{
1077-
ChannelMAC: GenerateMAC(pkiID2, channelA),
1077+
Channel_MAC: GenerateMAC(pkiID2, channelA),
10781078
},
10791079
},
10801080
}).NoopSign(),
@@ -1284,7 +1284,7 @@ func TestChannelGetPeers(t *testing.T) {
12841284
// and ensure that the StateInfo message doesn't count
12851285
gc = NewGossipChannel(pkiIDInOrg1, orgInChannelA, cs, channelA, adapter, &joinChanMsg{})
12861286
msg := &receivedMsg{PKIID: pkiIDInOrg1, msg: createStateInfoMsg(1, pkiIDInOrg1, channelA)}
1287-
msg.GetGossipMessage().GetStateInfo().ChannelMAC = GenerateMAC(pkiIDinOrg2, channelA)
1287+
msg.GetGossipMessage().GetStateInfo().Channel_MAC = GenerateMAC(pkiIDinOrg2, channelA)
12881288
gc.HandleMessage(msg)
12891289
assert.Len(t, gc.GetPeers(), 0)
12901290
}
@@ -1405,10 +1405,10 @@ func createStateInfoMsg(ledgerHeight int, pkiID common.PKIidType, channel common
14051405
Tag: proto.GossipMessage_CHAN_OR_ORG,
14061406
Content: &proto.GossipMessage_StateInfo{
14071407
StateInfo: &proto.StateInfo{
1408-
ChannelMAC: GenerateMAC(pkiID, channel),
1409-
Timestamp: &proto.PeerTime{IncNumber: uint64(time.Now().UnixNano()), SeqNum: 1},
1410-
Metadata: []byte(fmt.Sprintf("%d", ledgerHeight)),
1411-
PkiId: []byte(pkiID),
1408+
Channel_MAC: GenerateMAC(pkiID, channel),
1409+
Timestamp: &proto.PeerTime{IncNumber: uint64(time.Now().UnixNano()), SeqNum: 1},
1410+
Metadata: []byte(fmt.Sprintf("%d", ledgerHeight)),
1411+
PkiId: []byte(pkiID),
14121412
},
14131413
},
14141414
}).NoopSign()

gossip/gossip/chanstate.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (cs *channelState) isStopping() bool {
6060
func (cs *channelState) lookupChannelForMsg(msg proto.ReceivedMessage) channel.GossipChannel {
6161
if msg.GetGossipMessage().IsStateInfoPullRequestMsg() {
6262
sipr := msg.GetGossipMessage().GetStateInfoPullReq()
63-
mac := sipr.ChannelMAC
63+
mac := sipr.Channel_MAC
6464
pkiID := msg.GetConnectionInfo().ID
6565
return cs.getGossipChannelByMAC(mac, pkiID)
6666
}
@@ -80,7 +80,7 @@ func (cs *channelState) lookupChannelForGossipMsg(msg *proto.GossipMessage) chan
8080

8181
// Else, it's a StateInfo message.
8282
stateInfMsg := msg.GetStateInfo()
83-
return cs.getGossipChannelByMAC(stateInfMsg.ChannelMAC, stateInfMsg.PkiId)
83+
return cs.getGossipChannelByMAC(stateInfMsg.Channel_MAC, stateInfMsg.PkiId)
8484
}
8585

8686
func (cs *channelState) getGossipChannelByMAC(receivedMAC []byte, pkiID common.PKIidType) channel.GossipChannel {

gossip/gossip/gossip_impl.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1019,9 +1019,9 @@ func (g *gossipServiceImpl) sameOrgOrOurOrgPullFilter(msg proto.ReceivedMessage)
10191019
func (g *gossipServiceImpl) createStateInfoMsg(metadata []byte, chainID common.ChainID) (*proto.SignedGossipMessage, error) {
10201020
pkiID := g.comm.GetPKIid()
10211021
stateInfMsg := &proto.StateInfo{
1022-
ChannelMAC: channel.GenerateMAC(pkiID, chainID),
1023-
Metadata: metadata,
1024-
PkiId: g.comm.GetPKIid(),
1022+
Channel_MAC: channel.GenerateMAC(pkiID, chainID),
1023+
Metadata: metadata,
1024+
PkiId: g.comm.GetPKIid(),
10251025
Timestamp: &proto.PeerTime{
10261026
IncNumber: uint64(g.incTime.UnixNano()),
10271027
SeqNum: uint64(time.Now().UnixNano()),

protos/gossip/extensions_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func TestCheckGossipMessageTypes(t *testing.T) {
349349
// Create State info pull request
350350
msg = signedGossipMessage(channelID, GossipMessage_EMPTY, &GossipMessage_StateInfoPullReq{
351351
StateInfoPullReq: &StateInfoPullRequest{
352-
ChannelMAC: []byte{17},
352+
Channel_MAC: []byte{17},
353353
},
354354
})
355355

@@ -842,8 +842,8 @@ func stateInfoMessage(incNumber uint64, seqNum uint64, pkid []byte, mac []byte)
842842
IncNumber: incNumber,
843843
SeqNum: seqNum,
844844
},
845-
PkiId: pkid,
846-
ChannelMAC: mac,
845+
PkiId: pkid,
846+
Channel_MAC: mac,
847847
},
848848
}
849849
}

0 commit comments

Comments
 (0)