mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
core: simplify function CalcGasLimit
This commit is contained in:
parent
ef815c59a2
commit
5818015798
1 changed files with 5 additions and 13 deletions
|
|
@ -173,23 +173,15 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
|
|||
// the target if the baseline gas is lower.
|
||||
func CalcGasLimit(parentGasLimit, desiredLimit uint64) uint64 {
|
||||
delta := parentGasLimit/params.GasLimitBoundDivisor - 1
|
||||
limit := parentGasLimit
|
||||
if desiredLimit < params.MinGasLimit {
|
||||
desiredLimit = params.MinGasLimit
|
||||
}
|
||||
// If we're outside our allowed gas range, we try to hone towards them
|
||||
if limit < desiredLimit {
|
||||
limit = parentGasLimit + delta
|
||||
if limit > desiredLimit {
|
||||
limit = desiredLimit
|
||||
}
|
||||
return limit
|
||||
if parentGasLimit < desiredLimit {
|
||||
return min(parentGasLimit+delta, desiredLimit)
|
||||
}
|
||||
if limit > desiredLimit {
|
||||
limit = parentGasLimit - delta
|
||||
if limit < desiredLimit {
|
||||
limit = desiredLimit
|
||||
}
|
||||
if parentGasLimit > desiredLimit {
|
||||
return max(parentGasLimit-delta, desiredLimit)
|
||||
}
|
||||
return limit
|
||||
return parentGasLimit
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue