From 1e27707585af59958e0f48702682c4dd4e960c25 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Thu, 27 Jun 2019 13:35:58 -0700 Subject: [PATCH] allow mutiple blocks with the same height. print out error in that case --- node/node_explorer.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/node/node_explorer.go b/node/node_explorer.go index cb14a7fe5..9d009c4e2 100644 --- a/node/node_explorer.go +++ b/node/node_explorer.go @@ -88,11 +88,12 @@ func (node *Node) AddNewBlockForExplorer() { // Search for the next block in PbftLog and commit the block into blockchain for explorer node. for { blocks := node.Consensus.PbftLog.GetBlocksByNumber(node.Blockchain().CurrentBlock().NumberU64() + 1) - if len(blocks) > 1 { - utils.GetLogInstance().Error("We should have not received more than one block with the same block height.") - } else if len(blocks) == 0 { + if len(blocks) == 0 { break } else { + if len(blocks) > 1 { + utils.GetLogInstance().Error("We should have not received more than one block with the same block height.") + } utils.GetLogInstance().Info("Adding new block for explorer node", "blockHeight", blocks[0].NumberU64()) node.AddNewBlock(blocks[0]) // Clean up the blocks to avoid OOM.