mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
core, ethdb/leveldb: use min/max/clear
This commit is contained in:
parent
341647f186
commit
d26fd9b26e
5 changed files with 7 additions and 27 deletions
|
|
@ -132,10 +132,7 @@ func (f *chainFreezer) freezeThreshold(db ethdb.KeyValueReader) (uint64, error)
|
|||
if final == 0 && headLimit == 0 {
|
||||
return 0, errors.New("freezing threshold is not available")
|
||||
}
|
||||
if final > headLimit {
|
||||
return final, nil
|
||||
}
|
||||
return headLimit, nil
|
||||
return max(final, headLimit), nil
|
||||
}
|
||||
|
||||
// freeze is a background thread that periodically checks the blockchain for any
|
||||
|
|
|
|||
|
|
@ -36,10 +36,7 @@ func evictionPriority(basefeeJumps float64, txBasefeeJumps, blobfeeJumps, txBlob
|
|||
basefeePriority = evictionPriority1D(basefeeJumps, txBasefeeJumps)
|
||||
blobfeePriority = evictionPriority1D(blobfeeJumps, txBlobfeeJumps)
|
||||
)
|
||||
if basefeePriority < blobfeePriority {
|
||||
return basefeePriority
|
||||
}
|
||||
return blobfeePriority
|
||||
return min(basefeePriority, blobfeePriority)
|
||||
}
|
||||
|
||||
// evictionPriority1D calculates the eviction priority based on the algorithm
|
||||
|
|
|
|||
|
|
@ -426,10 +426,7 @@ func (c *bigModExp) RequiredGas(input []byte) uint64 {
|
|||
return math.MaxUint64
|
||||
}
|
||||
// 3. Minimum price of 200 gas
|
||||
if gas.Uint64() < 200 {
|
||||
return 200
|
||||
}
|
||||
return gas.Uint64()
|
||||
return max(200, gas.Uint64())
|
||||
}
|
||||
gas = modexpMultComplexity(gas)
|
||||
if adjExpLen.Cmp(big1) > 0 {
|
||||
|
|
|
|||
|
|
@ -73,10 +73,7 @@ func memoryCall(stack *Stack) (uint64, bool) {
|
|||
if overflow {
|
||||
return 0, true
|
||||
}
|
||||
if x > y {
|
||||
return x, false
|
||||
}
|
||||
return y, false
|
||||
return max(x, y), false
|
||||
}
|
||||
|
||||
func memoryDelegateCall(stack *Stack) (uint64, bool) {
|
||||
|
|
@ -88,10 +85,7 @@ func memoryDelegateCall(stack *Stack) (uint64, bool) {
|
|||
if overflow {
|
||||
return 0, true
|
||||
}
|
||||
if x > y {
|
||||
return x, false
|
||||
}
|
||||
return y, false
|
||||
return max(x, y), false
|
||||
}
|
||||
|
||||
func memoryStaticCall(stack *Stack) (uint64, bool) {
|
||||
|
|
@ -103,10 +97,7 @@ func memoryStaticCall(stack *Stack) (uint64, bool) {
|
|||
if overflow {
|
||||
return 0, true
|
||||
}
|
||||
if x > y {
|
||||
return x, false
|
||||
}
|
||||
return y, false
|
||||
return max(x, y), false
|
||||
}
|
||||
|
||||
func memoryReturn(stack *Stack) (uint64, bool) {
|
||||
|
|
|
|||
|
|
@ -358,9 +358,7 @@ func (db *Database) meter(refresh time.Duration, namespace string) {
|
|||
continue
|
||||
}
|
||||
// Iterate over all the leveldbTable rows, and accumulate the entries
|
||||
for j := 0; j < len(compactions[i%2]); j++ {
|
||||
compactions[i%2][j] = 0
|
||||
}
|
||||
clear(compactions[i%2])
|
||||
compactions[i%2][0] = stats.LevelSizes.Sum()
|
||||
for _, t := range stats.LevelDurations {
|
||||
compactions[i%2][1] += t.Nanoseconds()
|
||||
|
|
|
|||
Loading…
Reference in a new issue