prevent divide by zero

This commit is contained in:
Jared Wasinger 2025-03-31 16:18:02 +02:00
parent e703f92416
commit 7f0adc0bcb

View file

@ -100,7 +100,7 @@ func (r *resultStore) getFetchResult(headerNumber uint64) (item *fetchResult, in
// estimate an average block size based on the worst case: // estimate an average block size based on the worst case:
// a block filled with calldata containing all zeroes // a block filled with calldata containing all zeroes
// costing ~10 gas per byte of calldata. // costing ~10 gas per byte of calldata.
avgEstimatedBlockSize := (r.itemsGasUsed / (uint64(index) + 1)) / 10 avgEstimatedBlockSize := min((r.itemsGasUsed/(uint64(index)+1))/10, 524)
throttleThreshold := min(uint64(len(r.items)), uint64(blockCacheMemory)/avgEstimatedBlockSize) throttleThreshold := min(uint64(len(r.items)), uint64(blockCacheMemory)/avgEstimatedBlockSize)
throttle = index >= int(throttleThreshold) throttle = index >= int(throttleThreshold)