mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
core: fast exit if inserting stopped
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
cc1293b8f1
commit
ff0f3c50e9
1 changed files with 20 additions and 0 deletions
|
|
@ -1914,6 +1914,11 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
|
||||||
)
|
)
|
||||||
defer interrupt.Store(true) // terminate the prefetch at the end
|
defer interrupt.Store(true) // terminate the prefetch at the end
|
||||||
|
|
||||||
|
// Check for termination before starting block processing
|
||||||
|
if bc.insertStopped() {
|
||||||
|
return nil, errInsertionInterrupted
|
||||||
|
}
|
||||||
|
|
||||||
if bc.cacheConfig.TrieCleanNoPrefetch {
|
if bc.cacheConfig.TrieCleanNoPrefetch {
|
||||||
statedb, err = state.New(parentRoot, bc.statedb)
|
statedb, err = state.New(parentRoot, bc.statedb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1981,6 +1986,11 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for termination before starting transaction processing
|
||||||
|
if bc.insertStopped() {
|
||||||
|
return nil, errInsertionInterrupted
|
||||||
|
}
|
||||||
|
|
||||||
// Process block using the parent state as reference point
|
// Process block using the parent state as reference point
|
||||||
pstart := time.Now()
|
pstart := time.Now()
|
||||||
res, err := bc.processor.Process(block, statedb, bc.vmConfig)
|
res, err := bc.processor.Process(block, statedb, bc.vmConfig)
|
||||||
|
|
@ -1990,6 +2000,11 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
|
||||||
}
|
}
|
||||||
ptime := time.Since(pstart)
|
ptime := time.Since(pstart)
|
||||||
|
|
||||||
|
// Check for termination before validation
|
||||||
|
if bc.insertStopped() {
|
||||||
|
return nil, errInsertionInterrupted
|
||||||
|
}
|
||||||
|
|
||||||
vstart := time.Now()
|
vstart := time.Now()
|
||||||
if err := bc.validator.ValidateState(block, statedb, res, false); err != nil {
|
if err := bc.validator.ValidateState(block, statedb, res, false); err != nil {
|
||||||
bc.reportBlock(block, res, err)
|
bc.reportBlock(block, res, err)
|
||||||
|
|
@ -2046,6 +2061,11 @@ func (bc *BlockChain) processBlock(parentRoot common.Hash, block *types.Block, s
|
||||||
blockValidationTimer.Update(vtime - (triehash + trieUpdate)) // The time spent on block validation
|
blockValidationTimer.Update(vtime - (triehash + trieUpdate)) // The time spent on block validation
|
||||||
blockCrossValidationTimer.Update(xvtime) // The time spent on stateless cross validation
|
blockCrossValidationTimer.Update(xvtime) // The time spent on stateless cross validation
|
||||||
|
|
||||||
|
// Check for termination before writing to database
|
||||||
|
if bc.insertStopped() {
|
||||||
|
return nil, errInsertionInterrupted
|
||||||
|
}
|
||||||
|
|
||||||
// Write the block to the chain and get the status.
|
// Write the block to the chain and get the status.
|
||||||
var (
|
var (
|
||||||
wstart = time.Now()
|
wstart = time.Now()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue