From acd3eb93e8cba266359fdc59b9522bd96599c2a1 Mon Sep 17 00:00:00 2001 From: wit liu <765765346@qq.com> Date: Sun, 4 Jan 2026 20:00:47 +0800 Subject: [PATCH] core: use max to simplify function `CalcGasLimit` (#1902) --- core/block_validator.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/block_validator.go b/core/block_validator.go index d1c5645b07..a646fd127d 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -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 {