[viewchange] fixed gap calculation

we switch to use last block view ID from blockchain

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3448/head
Leo Chen 4 years ago
parent e891ca68dc
commit 1f9a2709b8
  1. 2
      consensus/view_change.go

@ -169,6 +169,8 @@ func (consensus *Consensus) getNextLeaderKey(viewID uint64) *bls.PublicKeyWrappe
consensus.getLogger().Error().Msg("[getNextLeaderKey] Failed to get current header from blockchain")
lastLeaderPubKey = consensus.LeaderPubKey
} else {
lastBlockViewID := curHeader.ViewID().Uint64()
gap = int(viewID - lastBlockViewID)
// this is the truth of the leader based on blockchain blocks
lastLeaderPubKey, err = consensus.getLeaderPubKeyFromCoinbase(curHeader)
if err != nil || lastLeaderPubKey == nil {

Loading…
Cancel
Save