Skip to content

Commit f41f4ff

Browse files
yeasyyacovm
authored andcommitted
[FAB-3333] Fix the inc_number in gossip msg
* Fix the field from inc_number to inc_num, which is aligned to the other field like seq_num in the same messsage structure. * Update the generated proto files. * Update the extensions.go to use the new field. Change-Id: Ic449e59c893f31ae3f193b2d6f302b2f96a36825 Signed-off-by: Baohua Yang <[email protected]>
1 parent 2a3ad9d commit f41f4ff

File tree

9 files changed

+124
-124
lines changed

9 files changed

+124
-124
lines changed

gossip/discovery/discovery_impl.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ func (d *gossipDiscoveryImpl) resurrectMember(am *proto.SignedGossipMessage, t p
548548
d.aliveLastTS[string(pkiID)] = &timestamp{
549549
lastSeen: time.Now(),
550550
seqNum: t.SeqNum,
551-
incTime: tsToTime(t.IncNumber),
551+
incTime: tsToTime(t.IncNum),
552552
}
553553

554554
var internalEndpoint string
@@ -722,8 +722,8 @@ func (d *gossipDiscoveryImpl) createAliveMessage(includeInternalEndpoint bool) *
722722
PkiId: pkiID,
723723
},
724724
Timestamp: &proto.PeerTime{
725-
IncNumber: uint64(d.incTime),
726-
SeqNum: seqNum,
725+
IncNum: uint64(d.incTime),
726+
SeqNum: seqNum,
727727
},
728728
},
729729
},
@@ -782,7 +782,7 @@ func (d *gossipDiscoveryImpl) learnExistingMembers(aliveArr []*proto.SignedGossi
782782
d.logger.Debug("Updating aliveness data:", am)
783783
// update existing aliveness data
784784
alive := d.aliveLastTS[string(am.Membership.PkiId)]
785-
alive.incTime = tsToTime(am.Timestamp.IncNumber)
785+
alive.incTime = tsToTime(am.Timestamp.IncNum)
786786
alive.lastSeen = time.Now()
787787
alive.seqNum = am.Timestamp.SeqNum
788788

@@ -811,7 +811,7 @@ func (d *gossipDiscoveryImpl) learnNewMembers(aliveMembers []*proto.SignedGossip
811811
continue
812812
}
813813
d.aliveLastTS[string(am.GetAliveMsg().Membership.PkiId)] = &timestamp{
814-
incTime: tsToTime(am.GetAliveMsg().Timestamp.IncNumber),
814+
incTime: tsToTime(am.GetAliveMsg().Timestamp.IncNum),
815815
lastSeen: time.Now(),
816816
seqNum: am.GetAliveMsg().Timestamp.SeqNum,
817817
}
@@ -825,7 +825,7 @@ func (d *gossipDiscoveryImpl) learnNewMembers(aliveMembers []*proto.SignedGossip
825825
continue
826826
}
827827
d.deadLastTS[string(dm.GetAliveMsg().Membership.PkiId)] = &timestamp{
828-
incTime: tsToTime(dm.GetAliveMsg().Timestamp.IncNumber),
828+
incTime: tsToTime(dm.GetAliveMsg().Timestamp.IncNum),
829829
lastSeen: time.Now(),
830830
seqNum: dm.GetAliveMsg().Timestamp.SeqNum,
831831
}
@@ -927,12 +927,12 @@ func equalPKIid(a, b common.PKIidType) bool {
927927
}
928928

929929
func same(a *timestamp, b *proto.PeerTime) bool {
930-
return uint64(a.incTime.UnixNano()) == b.IncNumber && a.seqNum == b.SeqNum
930+
return uint64(a.incTime.UnixNano()) == b.IncNum && a.seqNum == b.SeqNum
931931
}
932932

933933
func before(a *timestamp, b *proto.PeerTime) bool {
934-
return (uint64(a.incTime.UnixNano()) == b.IncNumber && a.seqNum < b.SeqNum) ||
935-
uint64(a.incTime.UnixNano()) < b.IncNumber
934+
return (uint64(a.incTime.UnixNano()) == b.IncNum && a.seqNum < b.SeqNum) ||
935+
uint64(a.incTime.UnixNano()) < b.IncNum
936936
}
937937

938938
func getAliveTimeInterval() time.Duration {

gossip/election/adapter.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ func (ai *adapterImpl) CreateMessage(isDeclaration bool) Msg {
138138
PkiId: ai.selfPKIid,
139139
IsDeclaration: isDeclaration,
140140
Timestamp: &proto.PeerTime{
141-
IncNumber: ai.incTime,
142-
SeqNum: seqNum,
141+
IncNum: ai.incTime,
142+
SeqNum: seqNum,
143143
},
144144
}
145145

gossip/gossip/channel/channel_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ func createStateInfoMsg(ledgerHeight int, pkiID common.PKIidType, channel common
14061406
Content: &proto.GossipMessage_StateInfo{
14071407
StateInfo: &proto.StateInfo{
14081408
Channel_MAC: GenerateMAC(pkiID, channel),
1409-
Timestamp: &proto.PeerTime{IncNumber: uint64(time.Now().UnixNano()), SeqNum: 1},
1409+
Timestamp: &proto.PeerTime{IncNum: uint64(time.Now().UnixNano()), SeqNum: 1},
14101410
Metadata: []byte(fmt.Sprintf("%d", ledgerHeight)),
14111411
PkiId: []byte(pkiID),
14121412
},

gossip/gossip/gossip_impl.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1023,8 +1023,8 @@ func (g *gossipServiceImpl) createStateInfoMsg(metadata []byte, chainID common.C
10231023
Metadata: metadata,
10241024
PkiId: g.comm.GetPKIid(),
10251025
Timestamp: &proto.PeerTime{
1026-
IncNumber: uint64(g.incTime.UnixNano()),
1027-
SeqNum: uint64(time.Now().UnixNano()),
1026+
IncNum: uint64(g.incTime.UnixNano()),
1027+
SeqNum: uint64(time.Now().UnixNano()),
10281028
},
10291029
}
10301030
m := &proto.GossipMessage{

gossip/gossip/gossip_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,8 @@ func createLeadershipMsg(isDeclaration bool, channel common.ChainID, incTime uin
10661066
IsDeclaration: isDeclaration,
10671067
PkiId: pkiid,
10681068
Timestamp: &proto.PeerTime{
1069-
IncNumber: incTime,
1070-
SeqNum: seqNum,
1069+
IncNum: incTime,
1070+
SeqNum: seqNum,
10711071
},
10721072
}
10731073

protos/gossip/extensions.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ func leaderInvalidationPolicy(thisMsg *LeadershipMessage, thatMsg *LeadershipMes
116116
}
117117

118118
func compareTimestamps(thisTS *PeerTime, thatTS *PeerTime) common.InvalidationResult {
119-
if thisTS.IncNumber == thatTS.IncNumber {
119+
if thisTS.IncNum == thatTS.IncNum {
120120
if thisTS.SeqNum > thatTS.SeqNum {
121121
return common.MessageInvalidates
122122
}
123123

124124
return common.MessageInvalidated
125125
}
126-
if thisTS.IncNumber < thatTS.IncNumber {
126+
if thisTS.IncNum < thatTS.IncNum {
127127
return common.MessageInvalidated
128128
}
129129
return common.MessageInvalidates

protos/gossip/extensions_test.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ func TestAliveMessageNoActionTaken(t *testing.T) {
150150
PkiId: []byte{17},
151151
},
152152
Timestamp: &PeerTime{
153-
IncNumber: 1,
154-
SeqNum: 1,
153+
IncNum: 1,
154+
SeqNum: 1,
155155
},
156156
Identity: []byte("peerID1"),
157157
},
@@ -165,8 +165,8 @@ func TestAliveMessageNoActionTaken(t *testing.T) {
165165
PkiId: []byte{15},
166166
},
167167
Timestamp: &PeerTime{
168-
IncNumber: 2,
169-
SeqNum: 2,
168+
IncNum: 2,
169+
SeqNum: 2,
170170
},
171171
Identity: []byte("peerID1"),
172172
},
@@ -226,8 +226,8 @@ func TestAliveMessageInvalidation(t *testing.T) {
226226
PkiId: []byte{17},
227227
},
228228
Timestamp: &PeerTime{
229-
IncNumber: 1,
230-
SeqNum: 1,
229+
IncNum: 1,
230+
SeqNum: 1,
231231
},
232232
Identity: []byte("peerID1"),
233233
},
@@ -241,8 +241,8 @@ func TestAliveMessageInvalidation(t *testing.T) {
241241
PkiId: []byte{17},
242242
},
243243
Timestamp: &PeerTime{
244-
IncNumber: 2,
245-
SeqNum: 2,
244+
IncNum: 2,
245+
SeqNum: 2,
246246
},
247247
Identity: []byte("peerID1"),
248248
},
@@ -256,8 +256,8 @@ func TestAliveMessageInvalidation(t *testing.T) {
256256
PkiId: []byte{17},
257257
},
258258
Timestamp: &PeerTime{
259-
IncNumber: 1,
260-
SeqNum: 2,
259+
IncNum: 1,
260+
SeqNum: 2,
261261
},
262262
Identity: []byte("peerID1"),
263263
},
@@ -365,8 +365,8 @@ func TestCheckGossipMessageTypes(t *testing.T) {
365365
Endpoint: "localhost",
366366
},
367367
Timestamp: &PeerTime{
368-
SeqNum: 1,
369-
IncNumber: 1,
368+
SeqNum: 1,
369+
IncNum: 1,
370370
},
371371
},
372372
})
@@ -827,20 +827,20 @@ func leadershipMessage(incNum uint64, seqNum uint64, pkid []byte) *GossipMessage
827827
PkiId: pkid,
828828
IsDeclaration: false,
829829
Timestamp: &PeerTime{
830-
IncNumber: incNum,
831-
SeqNum: seqNum,
830+
IncNum: incNum,
831+
SeqNum: seqNum,
832832
},
833833
},
834834
}
835835
}
836836

837-
func stateInfoMessage(incNumber uint64, seqNum uint64, pkid []byte, mac []byte) *GossipMessage_StateInfo {
837+
func stateInfoMessage(incNum uint64, seqNum uint64, pkid []byte, mac []byte) *GossipMessage_StateInfo {
838838
return &GossipMessage_StateInfo{
839839
StateInfo: &StateInfo{
840840
Metadata: []byte{},
841841
Timestamp: &PeerTime{
842-
IncNumber: incNumber,
843-
SeqNum: seqNum,
842+
IncNum: incNum,
843+
SeqNum: seqNum,
844844
},
845845
PkiId: pkid,
846846
Channel_MAC: mac,

0 commit comments

Comments
 (0)