diff --git a/common/countdown/exp_duration.go b/common/countdown/exp_duration.go index 10689bf630..0f1e20c4fb 100644 --- a/common/countdown/exp_duration.go +++ b/common/countdown/exp_duration.go @@ -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) diff --git a/core/block_validator.go b/core/block_validator.go index a646fd127d..cef59389ac 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -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 }