Skip to content

Commit 953bb21

Browse files
Jason YellickSrinivasan Muralidharan
Jason Yellick
authored and
Srinivasan Muralidharan
committed
[FAB-2472] Fix gossip proto style 2/3
https://jira.hyperledger.org/browse/FAB-2472 This is the second in a series of changesets to fix the gossip protos to conform to official proto style guidelines. This CR modifies the enums to be upper case and updates the corresponding go code as well. Change-Id: Ia75470b1a5fcf3a70128535e9da9e280dca1bd10 Signed-off-by: Jason Yellick <[email protected]>
1 parent 948de6b commit 953bb21

9 files changed

+115
-115
lines changed

gossip/gossip/certstore_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestCertStoreShouldSucceed(t *testing.T) {
110110

111111
func testCertificateUpdate(t *testing.T, updateFactory func(uint64) proto.ReceivedMessage, shouldSucceed bool) {
112112
config := pull.PullConfig{
113-
MsgType: proto.PullMsgType_IdentityMsg,
113+
MsgType: proto.PullMsgType_IDENTITY_MSG,
114114
PeerCountToSelect: 1,
115115
PullInterval: time.Millisecond * 500,
116116
Tag: proto.GossipMessage_EMPTY,
@@ -163,7 +163,7 @@ func testCertificateUpdate(t *testing.T, updateFactory func(uint64) proto.Receiv
163163
Hello: &proto.GossipHello{
164164
Nonce: 0,
165165
Metadata: nil,
166-
MsgType: proto.PullMsgType_IdentityMsg,
166+
MsgType: proto.PullMsgType_IDENTITY_MSG,
167167
},
168168
},
169169
}).NoopSign(),
@@ -273,7 +273,7 @@ func createUpdateMessage(nonce uint64, idMsg *proto.SignedGossipMessage) proto.R
273273
Tag: proto.GossipMessage_EMPTY,
274274
Content: &proto.GossipMessage_DataUpdate{
275275
DataUpdate: &proto.DataUpdate{
276-
MsgType: proto.PullMsgType_IdentityMsg,
276+
MsgType: proto.PullMsgType_IDENTITY_MSG,
277277
Nonce: nonce,
278278
Data: []*proto.Envelope{idMsg.Envelope},
279279
},
@@ -288,7 +288,7 @@ func createDigest(nonce uint64) proto.ReceivedMessage {
288288
Content: &proto.GossipMessage_DataDig{
289289
DataDig: &proto.DataDigest{
290290
Nonce: nonce,
291-
MsgType: proto.PullMsgType_IdentityMsg,
291+
MsgType: proto.PullMsgType_IDENTITY_MSG,
292292
Digests: []string{"A", "C"},
293293
},
294294
},

gossip/gossip/channel/channel.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (gc *gossipChannel) publishStateInfo() {
239239

240240
func (gc *gossipChannel) createBlockPuller() pull.Mediator {
241241
conf := pull.PullConfig{
242-
MsgType: proto.PullMsgType_BlockMessage,
242+
MsgType: proto.PullMsgType_BLOCK_MSG,
243243
Channel: []byte(gc.chainID),
244244
ID: gc.GetConf().ID,
245245
PeerCountToSelect: gc.GetConf().PullPeerNum,
@@ -409,7 +409,7 @@ func (gc *gossipChannel) HandleMessage(msg proto.ReceivedMessage) {
409409
}
410410
return
411411
}
412-
if m.IsPullMsg() && m.GetPullMsgType() == proto.PullMsgType_BlockMessage {
412+
if m.IsPullMsg() && m.GetPullMsgType() == proto.PullMsgType_BLOCK_MSG {
413413
if !gc.EligibleForChannel(discovery.NetworkMember{PKIid: msg.GetConnectionInfo().ID}) {
414414
gc.logger.Warning(msg.GetConnectionInfo().ID, "isn't eligible for channel", gc.chainID)
415415
return

gossip/gossip/channel/channel_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ func createDataUpdateMsg(nonce uint64) *proto.SignedGossipMessage {
854854
Tag: proto.GossipMessage_CHAN_AND_ORG,
855855
Content: &proto.GossipMessage_DataUpdate{
856856
DataUpdate: &proto.DataUpdate{
857-
MsgType: proto.PullMsgType_BlockMessage,
857+
MsgType: proto.PullMsgType_BLOCK_MSG,
858858
Nonce: nonce,
859859
Data: []*proto.Envelope{createDataMsg(10, channelA).Envelope, createDataMsg(11, channelA).Envelope},
860860
},
@@ -870,7 +870,7 @@ func createHelloMsg(PKIID common.PKIidType) *receivedMsg {
870870
Hello: &proto.GossipHello{
871871
Nonce: 500,
872872
Metadata: nil,
873-
MsgType: proto.PullMsgType_BlockMessage,
873+
MsgType: proto.PullMsgType_BLOCK_MSG,
874874
},
875875
},
876876
}
@@ -960,7 +960,7 @@ func simulatePullPhase(gc GossipChannel, t *testing.T, wg *sync.WaitGroup, mutat
960960
Channel: []byte(channelA),
961961
Content: &proto.GossipMessage_DataDig{
962962
DataDig: &proto.DataDigest{
963-
MsgType: proto.PullMsgType_BlockMessage,
963+
MsgType: proto.PullMsgType_BLOCK_MSG,
964964
Digests: []string{"10", "11"},
965965
Nonce: msg.GetHello().Nonce,
966966
},

gossip/gossip/gossip_impl.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func (g *gossipServiceImpl) handleMessage(m proto.ReceivedMessage) {
349349
g.forwardDiscoveryMsg(m)
350350
}
351351

352-
if msg.IsPullMsg() && msg.GetPullMsgType() == proto.PullMsgType_IdentityMsg {
352+
if msg.IsPullMsg() && msg.GetPullMsgType() == proto.PullMsgType_IDENTITY_MSG {
353353
g.certStore.handleMessage(m)
354354
}
355355
}
@@ -839,7 +839,7 @@ func (sa *discoverySecurityAdapter) validateAliveMsgSignature(m *proto.SignedGos
839839

840840
func (g *gossipServiceImpl) createCertStorePuller() pull.Mediator {
841841
conf := pull.PullConfig{
842-
MsgType: proto.PullMsgType_IdentityMsg,
842+
MsgType: proto.PullMsgType_IDENTITY_MSG,
843843
Channel: []byte(""),
844844
ID: g.conf.InternalEndpoint,
845845
PeerCountToSelect: g.conf.PullPeerNum,

gossip/gossip/pull/pullstore_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func createPullInstance(endpoint string, peer2PullInst map[string]*pullInstance)
117117
peer2PullInst[endpoint] = inst
118118

119119
conf := PullConfig{
120-
MsgType: proto.PullMsgType_BlockMessage,
120+
MsgType: proto.PullMsgType_BLOCK_MSG,
121121
Channel: []byte(""),
122122
ID: endpoint,
123123
PeerCountToSelect: 3,
@@ -300,7 +300,7 @@ func helloMsg() *proto.GossipMessage {
300300
Hello: &proto.GossipHello{
301301
Nonce: 0,
302302
Metadata: nil,
303-
MsgType: proto.PullMsgType_BlockMessage,
303+
MsgType: proto.PullMsgType_BLOCK_MSG,
304304
},
305305
},
306306
}
@@ -313,7 +313,7 @@ func reqMsg(digest ...string) *proto.GossipMessage {
313313
Nonce: 0,
314314
Content: &proto.GossipMessage_DataReq{
315315
DataReq: &proto.DataRequest{
316-
MsgType: proto.PullMsgType_BlockMessage,
316+
MsgType: proto.PullMsgType_BLOCK_MSG,
317317
Nonce: 0,
318318
Digests: digest,
319319
},

protos/gossip/extensions.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (m *GossipMessage) IsRemoteStateMessage() bool {
172172

173173
// GetPullMsgType returns the phase of the pull mechanism this GossipMessage belongs to
174174
// for example: Hello, Digest, etc.
175-
// If this isn't a pull message, PullMsgType_Undefined is returned.
175+
// If this isn't a pull message, PullMsgType_UNDEFINED is returned.
176176
func (m *GossipMessage) GetPullMsgType() PullMsgType {
177177
if helloMsg := m.GetHello(); helloMsg != nil {
178178
return helloMsg.MsgType
@@ -190,7 +190,7 @@ func (m *GossipMessage) GetPullMsgType() PullMsgType {
190190
return resMsg.MsgType
191191
}
192192

193-
return PullMsgType_Undefined
193+
return PullMsgType_UNDEFINED
194194
}
195195

196196
// IsChannelRestricted returns whether this GossipMessage should be routed
@@ -270,12 +270,12 @@ func (m *GossipMessage) IsTagLegal() error {
270270

271271
if m.IsPullMsg() {
272272
switch m.GetPullMsgType() {
273-
case PullMsgType_BlockMessage:
273+
case PullMsgType_BLOCK_MSG:
274274
if m.Tag != GossipMessage_CHAN_AND_ORG {
275275
return fmt.Errorf("Tag should be %s", GossipMessage_Tag_name[int32(GossipMessage_CHAN_AND_ORG)])
276276
}
277277
return nil
278-
case PullMsgType_IdentityMsg:
278+
case PullMsgType_IDENTITY_MSG:
279279
if m.Tag != GossipMessage_EMPTY {
280280
return fmt.Errorf("Tag should be %s", GossipMessage_Tag_name[int32(GossipMessage_EMPTY)])
281281
}

protos/gossip/extensions_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestToString(t *testing.T) {
7878
Content: &GossipMessage_DataUpdate{
7979
DataUpdate: &DataUpdate{
8080
Nonce: 11,
81-
MsgType: PullMsgType_BlockMessage,
81+
MsgType: PullMsgType_BLOCK_MSG,
8282
Data: envelopes(),
8383
},
8484
},

0 commit comments

Comments
 (0)