Skip to content

Commit 7f63742

Browse files
committed
[FAB-2642] Avoid overflow of seqNum in peer metastate
While gossip state transfer being initialized it check current height of the ledger and store in peer meta state value of height minus one, assuming that ledger is already contains at least one block (genesis). In this commit added a check of the ledger height value before initializing the state provider. Change-Id: I86b676d6aa2b4044c44d25725bb15aa90951c204 Signed-off-by: Artem Barger <[email protected]>
1 parent dc7d4d4 commit 7f63742

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

gossip/state/state.go

+5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ func NewGossipStateProvider(chainID string, g gossip.Gossip, committer committer
120120
_, commChan := g.Accept(remoteStateMsgFilter, true)
121121

122122
height, err := committer.LedgerHeight()
123+
if height == 0 {
124+
// Panic here since this is an indication of invalid situation which should not happen in normal
125+
// code path.
126+
logger.Panic("Committer height cannot be zero, ledger should include at least one block (genesis).")
127+
}
123128

124129
if err != nil {
125130
logger.Error("Could not read ledger info to obtain current ledger height due to: ", err)

0 commit comments

Comments
 (0)