core: avoid limit lower than MinGasLimit

if accidentally get a wrong value for gasFloor/gasCeil
This commit is contained in:
hepengfei 2019-06-12 20:13:47 +08:00
parent c8c3ebd593
commit cd003c2868

View file

@ -120,9 +120,7 @@ func CalcGasLimit(parent *types.Block, gasFloor, gasCeil uint64) uint64 {
from parentGasLimit * (2/3) parentGasUsed is.
*/
limit := parent.GasLimit() - decay + contrib
if limit < params.MinGasLimit {
limit = params.MinGasLimit
}
// If we're outside our allowed gas range, we try to hone towards them
if limit < gasFloor {
limit = parent.GasLimit() + decay
@ -135,5 +133,10 @@ func CalcGasLimit(parent *types.Block, gasFloor, gasCeil uint64) uint64 {
limit = gasCeil
}
}
if limit < params.MinGasLimit {
limit = params.MinGasLimit
}
return limit
}