messagepool: refactor CapGasFee logic to be cleaner

This commit is contained in:
Aayush 2023-10-10 11:20:26 -04:00
parent 1927b26abf
commit 00aad34194

View File

@ -225,17 +225,11 @@ func CapGasFee(mff dtypes.DefaultMaxFeeFunc, msg *types.Message, sendSpec *api.M
} }
gaslimit := types.NewInt(uint64(msg.GasLimit)) gaslimit := types.NewInt(uint64(msg.GasLimit))
totalFee := types.BigMul(msg.GasFeeCap, gaslimit)
if !maximizeFeeCap { if !maximizeFeeCap && totalFee.GreaterThan(maxFee) {
totalFee := types.BigMul(msg.GasFeeCap, gaslimit) msg.GasFeeCap = big.Div(maxFee, gaslimit)
if totalFee.LessThanEqual(maxFee) {
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
return
}
} }
msg.GasFeeCap = big.Div(maxFee, gaslimit)
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
} }