Skip to content

Commit 6721d8c

Browse files
committed
core: exit prefetch just after block processed
Signed-off-by: jsvisa <delweng@gmail.com>
1 parent 9fd3f8a commit 6721d8c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/blockchain.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,6 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
19121912
statedb *state.StateDB
19131913
interrupt atomic.Bool
19141914
)
1915-
defer interrupt.Store(true) // terminate the prefetch at the end
19161915

19171916
if bc.cacheConfig.TrieCleanNoPrefetch {
19181917
statedb, err = state.New(parentRoot, bc.statedb)
@@ -1984,6 +1983,8 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
19841983
// Process block using the parent state as reference point
19851984
pstart := time.Now()
19861985
res, err := bc.processor.Process(block, statedb, bc.vmConfig)
1986+
// Terminate the prefetch immediately after the block has been processed
1987+
interrupt.Store(true)
19871988
if err != nil {
19881989
bc.reportBlock(block, res, err)
19891990
return nil, err

0 commit comments

Comments
 (0)