mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
core: remove duplicated interruption checks
This commit is contained in:
parent
538ea2dea1
commit
d58a973c5d
1 changed files with 2 additions and 25 deletions
|
|
@ -278,9 +278,8 @@ type BlockChain struct {
|
||||||
txLookupLock sync.RWMutex
|
txLookupLock sync.RWMutex
|
||||||
txLookupCache *lru.Cache[common.Hash, txLookup]
|
txLookupCache *lru.Cache[common.Hash, txLookup]
|
||||||
|
|
||||||
quit chan struct{} // shutdown signal, closed in Stop.
|
stopping atomic.Bool // false if chain is running, true when stopped
|
||||||
stopping atomic.Bool // false if chain is running, true when stopped
|
procInterrupt atomic.Bool // interrupt signaler for block processing
|
||||||
procInterrupt atomic.Bool // interrupt signaler for block processing
|
|
||||||
|
|
||||||
engine consensus.Engine
|
engine consensus.Engine
|
||||||
validator Validator // Block and state validator interface
|
validator Validator // Block and state validator interface
|
||||||
|
|
@ -328,7 +327,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
||||||
db: db,
|
db: db,
|
||||||
triedb: triedb,
|
triedb: triedb,
|
||||||
triegc: prque.New[int64, common.Hash](nil),
|
triegc: prque.New[int64, common.Hash](nil),
|
||||||
quit: make(chan struct{}),
|
|
||||||
chainmu: syncx.NewClosableMutex(),
|
chainmu: syncx.NewClosableMutex(),
|
||||||
bodyCache: lru.NewCache[common.Hash, *types.Body](bodyCacheLimit),
|
bodyCache: lru.NewCache[common.Hash, *types.Body](bodyCacheLimit),
|
||||||
bodyRLPCache: lru.NewCache[common.Hash, rlp.RawValue](bodyCacheLimit),
|
bodyRLPCache: lru.NewCache[common.Hash, rlp.RawValue](bodyCacheLimit),
|
||||||
|
|
@ -1206,7 +1204,6 @@ func (bc *BlockChain) stopWithoutSaving() {
|
||||||
bc.scope.Close()
|
bc.scope.Close()
|
||||||
|
|
||||||
// Signal shutdown to all goroutines.
|
// Signal shutdown to all goroutines.
|
||||||
close(bc.quit)
|
|
||||||
bc.StopInsert()
|
bc.StopInsert()
|
||||||
|
|
||||||
// Now wait for all chain modifications to end and persistent goroutines to exit.
|
// Now wait for all chain modifications to end and persistent goroutines to exit.
|
||||||
|
|
@ -1914,11 +1911,6 @@ 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 {
|
||||||
|
|
@ -1986,11 +1978,6 @@ 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)
|
||||||
|
|
@ -2000,11 +1987,6 @@ 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)
|
||||||
|
|
@ -2061,11 +2043,6 @@ 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