Guards against size

This commit is contained in:
Lucia 2025-11-12 19:44:59 +13:00
parent 7368b34a4b
commit 6b01ca0db8

View file

@ -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