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))
if !maximizeFeeCap {
totalFee := types.BigMul(msg.GasFeeCap, gaslimit)
if totalFee.LessThanEqual(maxFee) {
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
return
}
}
if !maximizeFeeCap && totalFee.GreaterThan(maxFee) {
msg.GasFeeCap = big.Div(maxFee, gaslimit)
}
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
}