mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
core: add blockProcCount to avoid nested blockProcFeed events
This commit is contained in:
parent
d23e74c501
commit
cff467e424
1 changed files with 18 additions and 10 deletions
|
|
@ -222,14 +222,15 @@ type BlockChain struct {
|
||||||
statedb *state.CachingDB // State database to reuse between imports (contains state cache)
|
statedb *state.CachingDB // State database to reuse between imports (contains state cache)
|
||||||
txIndexer *txIndexer // Transaction indexer, might be nil if not enabled
|
txIndexer *txIndexer // Transaction indexer, might be nil if not enabled
|
||||||
|
|
||||||
hc *HeaderChain
|
hc *HeaderChain
|
||||||
rmLogsFeed event.Feed
|
rmLogsFeed event.Feed
|
||||||
chainFeed event.Feed
|
chainFeed event.Feed
|
||||||
chainHeadFeed event.Feed
|
chainHeadFeed event.Feed
|
||||||
logsFeed event.Feed
|
logsFeed event.Feed
|
||||||
blockProcFeed event.Feed
|
blockProcFeed event.Feed
|
||||||
scope event.SubscriptionScope
|
blockProcCounter int32
|
||||||
genesisBlock *types.Block
|
scope event.SubscriptionScope
|
||||||
|
genesisBlock *types.Block
|
||||||
|
|
||||||
// This mutex synchronizes chain write operations.
|
// This mutex synchronizes chain write operations.
|
||||||
// Readers don't need to take it, they can just read the database.
|
// Readers don't need to take it, they can just read the database.
|
||||||
|
|
@ -1616,8 +1617,15 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
|
||||||
if bc.insertStopped() {
|
if bc.insertStopped() {
|
||||||
return nil, 0, nil
|
return nil, 0, nil
|
||||||
}
|
}
|
||||||
bc.blockProcFeed.Send(true)
|
|
||||||
defer bc.blockProcFeed.Send(false)
|
if atomic.AddInt32(&bc.blockProcCounter, 1) == 1 {
|
||||||
|
bc.blockProcFeed.Send(true)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if atomic.AddInt32(&bc.blockProcCounter, -1) == 0 {
|
||||||
|
bc.blockProcFeed.Send(false)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// Start a parallel signature recovery (signer will fluke on fork transition, minimal perf loss)
|
// Start a parallel signature recovery (signer will fluke on fork transition, minimal perf loss)
|
||||||
SenderCacher().RecoverFromBlocks(types.MakeSigner(bc.chainConfig, chain[0].Number(), chain[0].Time()), chain)
|
SenderCacher().RecoverFromBlocks(types.MakeSigner(bc.chainConfig, chain[0].Number(), chain[0].Time()), chain)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue