Merge pull request #2993 from filecoin-project/fix/gasperf-div-0

Small fixes to mpool Trim
This commit is contained in:
Jakub Sztandera 2020-08-12 00:31:35 +02:00 committed by GitHub
commit 4b93c5d194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
}