@@ -1706,13 +1706,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
1706
1706
}
1707
1707
switch {
1708
1708
// First block is pruned, insert as sidechain and reorg only if TD grows enough
1709
- case err == consensus .ErrPrunedAncestor :
1709
+ case errors . Is ( err , consensus .ErrPrunedAncestor ) :
1710
1710
log .Debug ("Pruned ancestor, inserting as sidechain" , "number" , block .Number (), "hash" , block .Hash ())
1711
1711
return bc .insertSideChain (block , it )
1712
1712
1713
1713
// First block is future, shove it (and all children) to the future queue (unknown ancestor)
1714
- case err == consensus .ErrFutureBlock || (err == consensus .ErrUnknownAncestor && bc .futureBlocks .Contains (it .first ().ParentHash ())):
1715
- for block != nil && (it .index == 0 || err == consensus .ErrUnknownAncestor ) {
1714
+ case errors . Is ( err , consensus .ErrFutureBlock ) || (errors . Is ( err , consensus .ErrUnknownAncestor ) && bc .futureBlocks .Contains (it .first ().ParentHash ())):
1715
+ for block != nil && (it .index == 0 || errors . Is ( err , consensus .ErrUnknownAncestor ) ) {
1716
1716
log .Debug ("Future block, postponing import" , "number" , block .Number (), "hash" , block .Hash ())
1717
1717
if err := bc .addFutureBlock (block ); err != nil {
1718
1718
return it .index , err
@@ -1895,13 +1895,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
1895
1895
stats .report (chain , it .index , dirty )
1896
1896
}
1897
1897
// Any blocks remaining here? The only ones we care about are the future ones
1898
- if block != nil && err == consensus .ErrFutureBlock {
1898
+ if block != nil && errors . Is ( err , consensus .ErrFutureBlock ) {
1899
1899
if err := bc .addFutureBlock (block ); err != nil {
1900
1900
return it .index , err
1901
1901
}
1902
1902
block , err = it .next ()
1903
1903
1904
- for ; block != nil && err == consensus .ErrUnknownAncestor ; block , err = it .next () {
1904
+ for ; block != nil && errors . Is ( err , consensus .ErrUnknownAncestor ) ; block , err = it .next () {
1905
1905
if err := bc .addFutureBlock (block ); err != nil {
1906
1906
return it .index , err
1907
1907
}
@@ -1929,7 +1929,7 @@ func (bc *BlockChain) insertSideChain(block *types.Block, it *insertIterator) (i
1929
1929
// ones. Any other errors means that the block is invalid, and should not be written
1930
1930
// to disk.
1931
1931
err := consensus .ErrPrunedAncestor
1932
- for ; block != nil && (err == consensus .ErrPrunedAncestor ); block , err = it .next () {
1932
+ for ; block != nil && errors . Is (err , consensus .ErrPrunedAncestor ); block , err = it .next () {
1933
1933
// Check the canonical state root for that number
1934
1934
if number := block .NumberU64 (); current .NumberU64 () >= number {
1935
1935
canonical := bc .GetBlockByNumber (number )
0 commit comments