Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CalcGasLimit computes the gas limit of the next block after parent. It aims
- // to keep the baseline gas close to the provided target, and increase it towards
- // 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 limit > desiredLimit {
- limit = parentGasLimit - delta
- if limit < desiredLimit {
- limit = desiredLimit
- }
- }
- return limit
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement