Small fixes to mpool Trim

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-08-11 23:55:06 +02:00
parent d6f9383528
commit 2efb18f677
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -811,12 +811,15 @@ func (mc *msgChain) Trim(gasLimit int64, mp *MessagePool, baseFee types.BigInt,
mc.gasLimit -= mc.msgs[i].Message.GasLimit
if mc.gasLimit > 0 {
bp := 1.0
if mc.effPerf != 0 {
if mc.gasPerf != 0 { // prevent div by 0
bp = mc.effPerf / mc.gasPerf
}
mc.gasPerf = mp.getGasPerf(mc.gasReward, mc.gasLimit)
mc.effPerf = bp * mc.gasPerf
if mc.effPerf != 0 { // keep effPerf 0 if it is 0
mc.effPerf = bp * mc.gasPerf
}
} else {
mc.gasPerf = 0
}