From 6b01ca0db89e3b44dbb17d0c26b371c247d51f53 Mon Sep 17 00:00:00 2001 From: Lucia Date: Wed, 12 Nov 2025 19:44:59 +1300 Subject: [PATCH] Guards against size --- eth/downloader/queue.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index 9fe169d5f7..2adfdca328 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -334,7 +334,13 @@ func (q *queue) Results(block bool) []*fetchResult { } // Using the newly calibrated result size, figure out the new throttle limit // on the result cache - throttleThreshold := uint64((common.StorageSize(blockCacheMemory) + q.resultSize - 1) / q.resultSize) + var throttleThreshold uint64 + if q.resultSize > 0 { + throttleThreshold = uint64((common.StorageSize(blockCacheMemory) + q.resultSize - 1) / q.resultSize) + } else { + // Fall back to the initial cache size until we have samples to calibrate the average block size. + throttleThreshold = uint64(blockCacheInitialItems) + } throttleThreshold = q.resultCache.SetThrottleThreshold(throttleThreshold) // With results removed from the cache, wake throttled fetchers