mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +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
|
// retrievals that can be allowed until the cumulative block size hits a
|
||||||
// predetermined threshold (1 gb).
|
// predetermined threshold (1 gb).
|
||||||
func (r *resultStore) throttleThreshold() int {
|
func (r *resultStore) throttleThreshold() int {
|
||||||
index := r.itemsCount - 1
|
var avgGasUsed uint64
|
||||||
avgGasUsed := r.itemsGasUsed / (uint64(index) + 1)
|
if r.itemsCount > 0 {
|
||||||
|
avgGasUsed = r.itemsGasUsed / uint64(r.itemsCount)
|
||||||
|
}
|
||||||
blockSize := max(estWorstCaseBlockSize(avgGasUsed), headerSize)
|
blockSize := max(estWorstCaseBlockSize(avgGasUsed), headerSize)
|
||||||
|
|
||||||
throttleThreshold := min(uint64(len(r.items)), uint64(blockCacheMemory)/blockSize+1)
|
throttleThreshold := min(uint64(len(r.items)), uint64(blockCacheMemory)/blockSize+1)
|
||||||
return int(throttleThreshold)
|
return int(throttleThreshold)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue