From b238d71e16413afc26343e86918b74e9ff5ba373 Mon Sep 17 00:00:00 2001 From: Jacky Wang Date: Wed, 21 Oct 2020 15:04:23 -0700 Subject: [PATCH] [consensus] move UpdateConsensusInformation from onConsensusDone to commitBlock --- consensus/consensus_v2.go | 4 ++++ node/node_handler.go | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index e1b39044c..aaee214a9 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -521,6 +521,10 @@ func (consensus *Consensus) commitBlock(blk *types.Block, committedMsg *FBFTMess atomic.AddUint64(&consensus.blockNum, 1) consensus.SetCurBlockViewID(committedMsg.ViewID + 1) consensus.LeaderPubKey = committedMsg.SenderPubkeys[0] + // Update consensus keys at last so the change of leader status doesn't mess up normal flow + if blk.IsLastBlockInEpoch() { + consensus.SetMode(consensus.UpdateConsensusInformation()) + } consensus.ResetState() return nil } diff --git a/node/node_handler.go b/node/node_handler.go index 63749dcd0..037a667c1 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -395,10 +395,6 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block) error { // Broadcast client requested missing cross shard receipts if there is any node.BroadcastMissingCXReceipts() - // Update consensus keys at last so the change of leader status doesn't mess up normal flow - if newBlock.IsLastBlockInEpoch() { - node.Consensus.SetMode(node.Consensus.UpdateConsensusInformation()) - } if h := node.NodeConfig.WebHooks.Hooks; h != nil { if h.Availability != nil { for _, addr := range node.GetAddresses(newBlock.Epoch()) {