mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 12:46:44 +00:00
Guards against size
This commit is contained in:
parent
7368b34a4b
commit
6b01ca0db8
1 changed files with 7 additions and 1 deletions
|
|
@ -334,7 +334,13 @@ func (q *queue) Results(block bool) []*fetchResult {
|
||||||
}
|
}
|
||||||
// Using the newly calibrated result size, figure out the new throttle limit
|
// Using the newly calibrated result size, figure out the new throttle limit
|
||||||
// on the result cache
|
// 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)
|
throttleThreshold = q.resultCache.SetThrottleThreshold(throttleThreshold)
|
||||||
|
|
||||||
// With results removed from the cache, wake throttled fetchers
|
// With results removed from the cache, wake throttled fetchers
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue