core: use max to simplify function CalcGasLimit (#1902)

This commit is contained in:
wit liu 2026-01-04 20:00:47 +08:00 committed by GitHub
parent 267222d4a5
commit acd3eb93e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -189,10 +189,7 @@ func CalcGasLimit(parent *types.Block) uint64 {
at that usage) the amount increased/decreased depends on how far away
from parentGasLimit * (2/3) parentGasUsed is.
*/
limit := parent.GasLimit() - decay + contrib
if limit < params.MinGasLimit {
limit = params.MinGasLimit
}
limit := max(parent.GasLimit()-decay+contrib, params.MinGasLimit)
// 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 {