Skip to content

Commit 8556905

Browse files
authored
core: ensure state exists for prefetcher (#20627)
1 parent 38d1b0c commit 8556905

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

core/blockchain.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,18 +1654,17 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
16541654
// If we have a followup block, run that against the current state to pre-cache
16551655
// transactions and probabilistically some of the account/storage trie nodes.
16561656
var followupInterrupt uint32
1657-
16581657
if !bc.cacheConfig.TrieCleanNoPrefetch {
16591658
if followup, err := it.peek(); followup != nil && err == nil {
1660-
go func(start time.Time) {
1661-
throwaway, _ := state.New(parent.Root, bc.stateCache)
1662-
bc.prefetcher.Prefetch(followup, throwaway, bc.vmConfig, &followupInterrupt)
1659+
throwaway, _ := state.New(parent.Root, bc.stateCache)
1660+
go func(start time.Time, followup *types.Block, throwaway *state.StateDB, interrupt *uint32) {
1661+
bc.prefetcher.Prefetch(followup, throwaway, bc.vmConfig, interrupt)
16631662

16641663
blockPrefetchExecuteTimer.Update(time.Since(start))
1665-
if atomic.LoadUint32(&followupInterrupt) == 1 {
1664+
if atomic.LoadUint32(interrupt) == 1 {
16661665
blockPrefetchInterruptMeter.Mark(1)
16671666
}
1668-
}(time.Now())
1667+
}(time.Now(), followup, throwaway, &followupInterrupt)
16691668
}
16701669
}
16711670
// Process block using the parent state as reference point

0 commit comments

Comments
 (0)