From 7212dbd90f4cb8fe907617f804c8940db1ce657e Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 21 Oct 2019 16:07:47 -0400 Subject: fix the pool reset bug --- core/blockchain.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'core') diff --git a/core/blockchain.go b/core/blockchain.go index 174d403..046e1d4 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -1369,20 +1369,24 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. reorg = !currentPreserve && (blockPreserve || mrand.Float64() < 0.5) } } - if !bc.manualCanonical && reorg { - // Reorganise the chain if the parent is not the head block - if block.ParentHash() != currentBlock.Hash() { - if err := bc.reorg(currentBlock, block); err != nil { - return NonStatTy, err - } - } - // Write the positional metadata for transaction/receipt lookups and preimages - rawdb.WriteTxLookupEntries(batch, block) - rawdb.WritePreimages(batch, state.Preimages()) - + if bc.manualCanonical { status = CanonStatTy } else { - status = SideStatTy + if reorg { + // Reorganise the chain if the parent is not the head block + if block.ParentHash() != currentBlock.Hash() { + if err := bc.reorg(currentBlock, block); err != nil { + return NonStatTy, err + } + } + // Write the positional metadata for transaction/receipt lookups and preimages + rawdb.WriteTxLookupEntries(batch, block) + rawdb.WritePreimages(batch, state.Preimages()) + + status = CanonStatTy + } else { + status = SideStatTy + } } if err := batch.Write(); err != nil { return NonStatTy, err -- cgit v1.2.3