Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Enable tx prefetcher for multiple blocks #916

Merged
merged 2 commits into from
Mar 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1681,15 +1681,14 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
var followupInterrupt uint32

if bc.cacheConfig.TrieNodeCacheConfig.NumFetcherPrefetchWorker > 0 {
// if fetcher works and only a block is given, use prefetchTxWorker
if len(chain) == 1 {
for ti := range block.Transactions() {
select {
case bc.prefetchTxCh <- prefetchTx{ti, block, &followupInterrupt}:
default:
}
// Tx prefetcher is enabled for all cases (both single and multiple block insertion).
for ti := range block.Transactions() {
select {
case bc.prefetchTxCh <- prefetchTx{ti, block, &followupInterrupt}:
default:
}
} else if i < len(chain)-1 {
}
if i < len(chain)-1 {
// current block is not the last one, so prefetch the right next block
followup := chain[i+1]
go func(start time.Time) {
Expand Down