mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
common, core: use min to simplify code (#1939)
This commit is contained in:
parent
80db09613e
commit
283d208fa3
2 changed files with 2 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue