mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
core: use max to simplify function CalcGasLimit (#1902)
This commit is contained in:
parent
267222d4a5
commit
acd3eb93e8
1 changed files with 1 additions and 4 deletions
|
|
@ -189,10 +189,7 @@ func CalcGasLimit(parent *types.Block) uint64 {
|
||||||
at that usage) the amount increased/decreased depends on how far away
|
at that usage) the amount increased/decreased depends on how far away
|
||||||
from parentGasLimit * (2/3) parentGasUsed is.
|
from parentGasLimit * (2/3) parentGasUsed is.
|
||||||
*/
|
*/
|
||||||
limit := parent.GasLimit() - decay + contrib
|
limit := max(parent.GasLimit()-decay+contrib, params.MinGasLimit)
|
||||||
if limit < params.MinGasLimit {
|
|
||||||
limit = params.MinGasLimit
|
|
||||||
}
|
|
||||||
// however, if we're now below the target (TargetGasLimit) we increase the
|
// however, if we're now below the target (TargetGasLimit) we increase the
|
||||||
// limit as much as we can (parentGasLimit / 1024 -1)
|
// limit as much as we can (parentGasLimit / 1024 -1)
|
||||||
if limit < params.TargetGasLimit {
|
if limit < params.TargetGasLimit {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue