core/state: fix prefetch on single core CPU

We need at least one prefetch goroutine. SetLimit(0) would block prefetch.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-06-21 15:26:53 +02:00
parent 6eab053088
commit c4597cfdf0
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E

View file

@ -57,7 +57,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
workers errgroup.Group workers errgroup.Group
reader = statedb.Reader() reader = statedb.Reader()
) )
workers.SetLimit(4 * runtime.NumCPU() / 5) // Aggressively run the prefetching workers.SetLimit(max(1, 4*runtime.NumCPU()/5)) // Aggressively run the prefetching
// Iterate over and process the individual transactions // Iterate over and process the individual transactions
for i, tx := range block.Transactions() { for i, tx := range block.Transactions() {