common, core: use min to simplify code (#1939)

This commit is contained in:
Daniel Liu 2026-01-16 18:23:39 +08:00 committed by GitHub
parent 80db09613e
commit 283d208fa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 8 deletions

View file

@ -42,10 +42,7 @@ func (d *ExpTimeoutDuration) GetTimeoutDuration(currentRound, highestRound types
power := float64(1)
// below statement must be true, just to prevent negative result
if highestRound < currentRound {
exp := uint8(currentRound-highestRound) - 1
if exp > d.maxExponent {
exp = d.maxExponent
}
exp := min(uint8(currentRound-highestRound) - 1, d.maxExponent)
power = math.Pow(d.base, float64(exp))
}
return d.duration * time.Duration(power)

View file

@ -193,10 +193,7 @@ func CalcGasLimit(parent *types.Block) uint64 {
// however, if we're now below the target (TargetGasLimit) we increase the
// limit as much as we can (parentGasLimit / 1024 -1)
if limit < params.TargetGasLimit {
limit = parent.GasLimit() + decay
if limit > params.TargetGasLimit {
limit = params.TargetGasLimit
}
limit = min(parent.GasLimit() + decay, params.TargetGasLimit)
}
return limit
}