mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 07:06:42 +00:00
eth/downloader: remove TODO and condense surrounding code.
This commit is contained in:
parent
cca407b2a1
commit
29435f8f31
1 changed files with 4 additions and 3 deletions
|
|
@ -123,10 +123,11 @@ func (r *resultStore) isThrottled(index int) bool {
|
|||
// retrievals that can be allowed until the cumulative block size hits a
|
||||
// predetermined threshold (1 gb).
|
||||
func (r *resultStore) throttleThreshold() int {
|
||||
index := r.itemsCount - 1
|
||||
avgGasUsed := r.itemsGasUsed / (uint64(index) + 1)
|
||||
var avgGasUsed uint64
|
||||
if r.itemsCount > 0 {
|
||||
avgGasUsed = r.itemsGasUsed / uint64(r.itemsCount)
|
||||
}
|
||||
blockSize := max(estWorstCaseBlockSize(avgGasUsed), headerSize)
|
||||
|
||||
throttleThreshold := min(uint64(len(r.items)), uint64(blockCacheMemory)/blockSize+1)
|
||||
return int(throttleThreshold)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue