core: add blockProcCount to avoid nested blockProcFeed events

pull/31065/head
Zsolt Felfoldi 4 days ago
parent d23e74c501
commit cff467e424
  1. 10
      core/blockchain.go

@ -228,6 +228,7 @@ type BlockChain struct {
chainHeadFeed event.Feed
logsFeed event.Feed
blockProcFeed event.Feed
blockProcCounter int32
scope event.SubscriptionScope
genesisBlock *types.Block
@ -1616,8 +1617,15 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool, makeWitness
if bc.insertStopped() {
return nil, 0, nil
}
if atomic.AddInt32(&bc.blockProcCounter, 1) == 1 {
bc.blockProcFeed.Send(true)
defer bc.blockProcFeed.Send(false)
}
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)
SenderCacher().RecoverFromBlocks(types.MakeSigner(bc.chainConfig, chain[0].Number(), chain[0].Time()), chain)

Loading…
Cancel
Save