Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1806,12 +1806,12 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
block, err := it.next()
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):
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)) {
if err := bc.addFutureBlock(block); err != nil {
return it.index, events, coalescedLogs, err
}
Expand All @@ -1827,11 +1827,11 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
// 1. We did a roll-back, and should now do a re-import
// 2. The block is stored as a sidechain, and is lying about it's stateroot, and passes a stateroot
// from the canonical chain, which has not been verified.
case err == ErrKnownBlock:
case errors.Is(err, ErrKnownBlock):
// Skip all known blocks that behind us
current := bc.CurrentBlock().Number.Uint64()

for block != nil && err == ErrKnownBlock && current >= block.NumberU64() {
for block != nil && errors.Is(err, ErrKnownBlock) && current >= block.NumberU64() {
stats.ignored++
block, err = it.next()
}
Expand Down Expand Up @@ -1934,13 +1934,13 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
}

// 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, events, coalescedLogs, 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, events, coalescedLogs, err
}
Expand Down Expand Up @@ -2064,7 +2064,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 >= number {
if canonical := bc.GetBlockByNumber(number); canonical != nil && canonical.Root() == block.Root() {
Expand Down Expand Up @@ -2225,13 +2225,13 @@ func (bc *BlockChain) getResultBlock(block *types.Block, verifiedM2 bool) (*Resu
bstart := time.Now()
err := bc.validator.ValidateBody(block)
switch {
case err == ErrKnownBlock:
case errors.Is(err, ErrKnownBlock):
// Block and state both already known. However if the current block is below
// this number we did a rollback and we should reimport it nonetheless.
if bc.CurrentBlock().Number.Uint64() >= block.NumberU64() {
return nil, ErrKnownBlock
}
case err == consensus.ErrPrunedAncestor:
case errors.Is(err, consensus.ErrPrunedAncestor):
// Block competing with the canonical chain, store in the db, but don't process
// until the competitor TD goes above the canonical TD
currentBlock := bc.CurrentBlock()
Expand Down Expand Up @@ -2286,7 +2286,7 @@ func (bc *BlockChain) getResultBlock(block *types.Block, verifiedM2 bool) (*Resu
receipts, logs, usedGas, err := bc.processor.ProcessBlockNoValidator(calculatedBlock, statedb, tradingState, bc.vmConfig, feeCapacity)
process := time.Since(bstart)
if err != nil {
if err != ErrStopPreparingBlock {
if !errors.Is(err, ErrStopPreparingBlock) {
bc.reportBlock(block, receipts, err)
}
return nil, err
Expand Down