From 5d16717fd316246230a88e1fdd1b73265d58d9dc Mon Sep 17 00:00:00 2001 From: ywzqwwt <752252086@qq.com> Date: Fri, 15 Feb 2019 15:40:07 +0800 Subject: [PATCH] core/snailchain.go: continue to iteration if ErrPrunedAncestor --- core/blockchain.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 49aedf6693..54ca6d33d4 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -748,7 +748,7 @@ func (bc *BlockChain) procFutureBlocks() { type WriteStatus byte const ( - NonStatTy WriteStatus = iota + NonStatTy WriteStatus = iota CanonStatTy SideStatTy ) @@ -1138,7 +1138,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, [] case err == consensus.ErrPrunedAncestor: return bc.insertSidechain(it) - // First block is future, shove it (and all children) to the future queue (unknown ancestor) + // 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) { if err := bc.addFutureBlock(block); err != nil { @@ -1152,10 +1152,10 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, [] // If there are any still remaining, mark as ignored return it.index, events, coalescedLogs, err - // First block (and state) is known - // 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. + // First block (and state) is known + // 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: // Skip all known blocks that behind us current := bc.CurrentBlock().NumberU64() @@ -1166,14 +1166,14 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, [] } // Falls through to the block import - // Some other error occurred, abort + // Some other error occurred, abort case err != nil: stats.ignored += len(it.chain) bc.reportBlock(block, nil, err) return it.index, events, coalescedLogs, err } // No validation errors for the first block (or chain prefix skipped) - for ; block != nil && err == nil; block, err = it.next() { + for ; block != nil && (err == nil || err == consensus.ErrPrunedAncestor); block, err = it.next() { // If the chain is terminating, stop processing blocks if atomic.LoadInt32(&bc.procInterrupt) == 1 { log.Debug("Premature abort during blocks processing")