eth/downloader: use nresults

This commit is contained in:
healthykim 2026-04-17 11:12:22 +02:00
parent a94f0a8ac8
commit 1c8dd7fe0e

View file

@ -562,9 +562,10 @@ func (q *queue) DeliverBodies(id string, hashes eth.BlockBodyHashes, bodies []et
q.lock.Lock() q.lock.Lock()
defer q.lock.Unlock() defer q.lock.Unlock()
txLists := make([][]*types.Transaction, len(bodies)) nresults := len(hashes.TransactionRoots)
uncleLists := make([][]*types.Header, len(bodies)) txLists := make([][]*types.Transaction, nresults)
withdrawalLists := make([][]*types.Withdrawal, len(bodies)) uncleLists := make([][]*types.Header, nresults)
withdrawalLists := make([][]*types.Withdrawal, nresults)
validate := func(index int, header *types.Header) error { validate := func(index int, header *types.Header) error {
// Detect skipped response: the peer returned an empty body for a non-empty block // Detect skipped response: the peer returned an empty body for a non-empty block
@ -618,8 +619,9 @@ func (q *queue) DeliverBodies(id string, hashes eth.BlockBodyHashes, bodies []et
result.Withdrawals = withdrawalLists[index] result.Withdrawals = withdrawalLists[index]
result.SetBodyDone() result.SetBodyDone()
} }
return q.deliver(id, q.blockTaskPool, q.blockTaskQueue, q.blockPendPool, return q.deliver(id, q.blockTaskPool, q.blockTaskQueue, q.blockPendPool,
bodyReqTimer, bodyInMeter, bodyDropMeter, len(bodies), validate, reconstruct) bodyReqTimer, bodyInMeter, bodyDropMeter, nresults, validate, reconstruct)
} }
// DeliverReceipts injects a receipt retrieval response into the results queue. // DeliverReceipts injects a receipt retrieval response into the results queue.