public long GetGasLimit(BlockHeader parentHeader)
        {
            long         gasLimit       = parentHeader.GasLimit;
            long         newBlockNumber = parentHeader.Number + 1;
            IReleaseSpec spec           = _specProvider.GetSpec(newBlockNumber);

            gasLimit = Eip1559GasLimitAdjuster.AdjustGasLimit(spec, gasLimit, newBlockNumber);
            return(gasLimit);
        }
Beispiel #2
0
        public long GetGasLimit(BlockHeader parentHeader)
        {
            long parentGasLimit = parentHeader.GasLimit;
            long gasLimit       = parentGasLimit;

            long?        targetGasLimit = _miningConfig.TargetBlockGasLimit;
            long         newBlockNumber = parentHeader.Number + 1;
            IReleaseSpec spec           = _specProvider.GetSpec(newBlockNumber);

            if (targetGasLimit != null)
            {
                long maxGasLimitDifference = Math.Max(0, parentGasLimit / spec.GasLimitBoundDivisor - 1);
                gasLimit = targetGasLimit.Value > parentGasLimit
                    ? parentGasLimit + Math.Min(targetGasLimit.Value - parentGasLimit, maxGasLimitDifference)
                    : parentGasLimit - Math.Min(parentGasLimit - targetGasLimit.Value, maxGasLimitDifference);
            }

            gasLimit = Eip1559GasLimitAdjuster.AdjustGasLimit(spec, gasLimit, newBlockNumber);
            return(gasLimit);
        }