Skip to content

Commit

Permalink
[FAB-2472] Fix gossip proto style 2/3
Browse files Browse the repository at this point in the history
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 <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick authored and Srinivasan Muralidharan committed Mar 5, 2017
1 parent 948de6b commit 953bb21
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 115 deletions.
8 changes: 4 additions & 4 deletions gossip/gossip/certstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestCertStoreShouldSucceed(t *testing.T) {

func testCertificateUpdate(t *testing.T, updateFactory func(uint64) proto.ReceivedMessage, shouldSucceed bool) {
config := pull.PullConfig{
MsgType: proto.PullMsgType_IdentityMsg,
MsgType: proto.PullMsgType_IDENTITY_MSG,
PeerCountToSelect: 1,
PullInterval: time.Millisecond * 500,
Tag: proto.GossipMessage_EMPTY,
Expand Down Expand Up @@ -163,7 +163,7 @@ func testCertificateUpdate(t *testing.T, updateFactory func(uint64) proto.Receiv
Hello: &proto.GossipHello{
Nonce: 0,
Metadata: nil,
MsgType: proto.PullMsgType_IdentityMsg,
MsgType: proto.PullMsgType_IDENTITY_MSG,
},
},
}).NoopSign(),
Expand Down Expand Up @@ -273,7 +273,7 @@ func createUpdateMessage(nonce uint64, idMsg *proto.SignedGossipMessage) proto.R
Tag: proto.GossipMessage_EMPTY,
Content: &proto.GossipMessage_DataUpdate{
DataUpdate: &proto.DataUpdate{
MsgType: proto.PullMsgType_IdentityMsg,
MsgType: proto.PullMsgType_IDENTITY_MSG,
Nonce: nonce,
Data: []*proto.Envelope{idMsg.Envelope},
},
Expand All @@ -288,7 +288,7 @@ func createDigest(nonce uint64) proto.ReceivedMessage {
Content: &proto.GossipMessage_DataDig{
DataDig: &proto.DataDigest{
Nonce: nonce,
MsgType: proto.PullMsgType_IdentityMsg,
MsgType: proto.PullMsgType_IDENTITY_MSG,
Digests: []string{"A", "C"},
},
},
Expand Down
4 changes: 2 additions & 2 deletions gossip/gossip/channel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func (gc *gossipChannel) publishStateInfo() {

func (gc *gossipChannel) createBlockPuller() pull.Mediator {
conf := pull.PullConfig{
MsgType: proto.PullMsgType_BlockMessage,
MsgType: proto.PullMsgType_BLOCK_MSG,
Channel: []byte(gc.chainID),
ID: gc.GetConf().ID,
PeerCountToSelect: gc.GetConf().PullPeerNum,
Expand Down Expand Up @@ -409,7 +409,7 @@ func (gc *gossipChannel) HandleMessage(msg proto.ReceivedMessage) {
}
return
}
if m.IsPullMsg() && m.GetPullMsgType() == proto.PullMsgType_BlockMessage {
if m.IsPullMsg() && m.GetPullMsgType() == proto.PullMsgType_BLOCK_MSG {
if !gc.EligibleForChannel(discovery.NetworkMember{PKIid: msg.GetConnectionInfo().ID}) {
gc.logger.Warning(msg.GetConnectionInfo().ID, "isn't eligible for channel", gc.chainID)
return
Expand Down
6 changes: 3 additions & 3 deletions gossip/gossip/channel/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ func createDataUpdateMsg(nonce uint64) *proto.SignedGossipMessage {
Tag: proto.GossipMessage_CHAN_AND_ORG,
Content: &proto.GossipMessage_DataUpdate{
DataUpdate: &proto.DataUpdate{
MsgType: proto.PullMsgType_BlockMessage,
MsgType: proto.PullMsgType_BLOCK_MSG,
Nonce: nonce,
Data: []*proto.Envelope{createDataMsg(10, channelA).Envelope, createDataMsg(11, channelA).Envelope},
},
Expand All @@ -870,7 +870,7 @@ func createHelloMsg(PKIID common.PKIidType) *receivedMsg {
Hello: &proto.GossipHello{
Nonce: 500,
Metadata: nil,
MsgType: proto.PullMsgType_BlockMessage,
MsgType: proto.PullMsgType_BLOCK_MSG,
},
},
}
Expand Down Expand Up @@ -960,7 +960,7 @@ func simulatePullPhase(gc GossipChannel, t *testing.T, wg *sync.WaitGroup, mutat
Channel: []byte(channelA),
Content: &proto.GossipMessage_DataDig{
DataDig: &proto.DataDigest{
MsgType: proto.PullMsgType_BlockMessage,
MsgType: proto.PullMsgType_BLOCK_MSG,
Digests: []string{"10", "11"},
Nonce: msg.GetHello().Nonce,
},
Expand Down
4 changes: 2 additions & 2 deletions gossip/gossip/gossip_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (g *gossipServiceImpl) handleMessage(m proto.ReceivedMessage) {
g.forwardDiscoveryMsg(m)
}

if msg.IsPullMsg() && msg.GetPullMsgType() == proto.PullMsgType_IdentityMsg {
if msg.IsPullMsg() && msg.GetPullMsgType() == proto.PullMsgType_IDENTITY_MSG {
g.certStore.handleMessage(m)
}
}
Expand Down Expand Up @@ -839,7 +839,7 @@ func (sa *discoverySecurityAdapter) validateAliveMsgSignature(m *proto.SignedGos

func (g *gossipServiceImpl) createCertStorePuller() pull.Mediator {
conf := pull.PullConfig{
MsgType: proto.PullMsgType_IdentityMsg,
MsgType: proto.PullMsgType_IDENTITY_MSG,
Channel: []byte(""),
ID: g.conf.InternalEndpoint,
PeerCountToSelect: g.conf.PullPeerNum,
Expand Down
6 changes: 3 additions & 3 deletions gossip/gossip/pull/pullstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func createPullInstance(endpoint string, peer2PullInst map[string]*pullInstance)
peer2PullInst[endpoint] = inst

conf := PullConfig{
MsgType: proto.PullMsgType_BlockMessage,
MsgType: proto.PullMsgType_BLOCK_MSG,
Channel: []byte(""),
ID: endpoint,
PeerCountToSelect: 3,
Expand Down Expand Up @@ -300,7 +300,7 @@ func helloMsg() *proto.GossipMessage {
Hello: &proto.GossipHello{
Nonce: 0,
Metadata: nil,
MsgType: proto.PullMsgType_BlockMessage,
MsgType: proto.PullMsgType_BLOCK_MSG,
},
},
}
Expand All @@ -313,7 +313,7 @@ func reqMsg(digest ...string) *proto.GossipMessage {
Nonce: 0,
Content: &proto.GossipMessage_DataReq{
DataReq: &proto.DataRequest{
MsgType: proto.PullMsgType_BlockMessage,
MsgType: proto.PullMsgType_BLOCK_MSG,
Nonce: 0,
Digests: digest,
},
Expand Down
8 changes: 4 additions & 4 deletions protos/gossip/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (m *GossipMessage) IsRemoteStateMessage() bool {

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

return PullMsgType_Undefined
return PullMsgType_UNDEFINED
}

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

if m.IsPullMsg() {
switch m.GetPullMsgType() {
case PullMsgType_BlockMessage:
case PullMsgType_BLOCK_MSG:
if m.Tag != GossipMessage_CHAN_AND_ORG {
return fmt.Errorf("Tag should be %s", GossipMessage_Tag_name[int32(GossipMessage_CHAN_AND_ORG)])
}
return nil
case PullMsgType_IdentityMsg:
case PullMsgType_IDENTITY_MSG:
if m.Tag != GossipMessage_EMPTY {
return fmt.Errorf("Tag should be %s", GossipMessage_Tag_name[int32(GossipMessage_EMPTY)])
}
Expand Down
2 changes: 1 addition & 1 deletion protos/gossip/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestToString(t *testing.T) {
Content: &GossipMessage_DataUpdate{
DataUpdate: &DataUpdate{
Nonce: 11,
MsgType: PullMsgType_BlockMessage,
MsgType: PullMsgType_BLOCK_MSG,
Data: envelopes(),
},
},
Expand Down
Loading

0 comments on commit 953bb21

Please sign in to comment.