diff --git a/core/blockchain.go b/core/blockchain.go index 57796d8c6c..499c8eee67 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1706,13 +1706,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er } switch { // First block is pruned, insert as sidechain and reorg only if TD grows enough - case err == consensus.ErrPrunedAncestor: + case errors.Is(err, consensus.ErrPrunedAncestor): log.Debug("Pruned ancestor, inserting as sidechain", "number", block.Number(), "hash", block.Hash()) return bc.insertSideChain(block, it) // First block is future, shove it (and all children) to the future queue (unknown ancestor) - case err == consensus.ErrFutureBlock || (err == consensus.ErrUnknownAncestor && bc.futureBlocks.Contains(it.first().ParentHash())): - for block != nil && (it.index == 0 || err == consensus.ErrUnknownAncestor) { + case errors.Is(err, consensus.ErrFutureBlock) || (errors.Is(err, consensus.ErrUnknownAncestor) && bc.futureBlocks.Contains(it.first().ParentHash())): + for block != nil && (it.index == 0 || errors.Is(err, consensus.ErrUnknownAncestor)) { log.Debug("Future block, postponing import", "number", block.Number(), "hash", block.Hash()) if err := bc.addFutureBlock(block); err != nil { return it.index, err @@ -1895,13 +1895,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er stats.report(chain, it.index, dirty) } // Any blocks remaining here? The only ones we care about are the future ones - if block != nil && err == consensus.ErrFutureBlock { + if block != nil && errors.Is(err, consensus.ErrFutureBlock) { if err := bc.addFutureBlock(block); err != nil { return it.index, err } block, err = it.next() - for ; block != nil && err == consensus.ErrUnknownAncestor; block, err = it.next() { + for ; block != nil && errors.Is(err, consensus.ErrUnknownAncestor); block, err = it.next() { if err := bc.addFutureBlock(block); err != nil { return it.index, err } @@ -1929,7 +1929,7 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator) (i // ones. Any other errors means that the block is invalid, and should not be written // to disk. err := consensus.ErrPrunedAncestor - for ; block != nil && (err == consensus.ErrPrunedAncestor); block, err = it.next() { + for ; block != nil && errors.Is(err, consensus.ErrPrunedAncestor); block, err = it.next() { // Check the canonical state root for that number if number := block.NumberU64(); current.NumberU64() >= number { canonical := bc.GetBlockByNumber(number)