Skip to content

Commit

Permalink
Merge pull request ethereumjs#27 from cdetrio/master
Browse files Browse the repository at this point in the history
use bignum for gas limit
  • Loading branch information
wanderer authored Jun 3, 2017
2 parents 3f9296c + a06847c commit b4f8033
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions header.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ BlockHeader.prototype.validateDifficulty = function (parentBlock) {
* @returns {Boolean}
*/
BlockHeader.prototype.validateGasLimit = function (parentBlock) {
const pGasLimit = utils.bufferToInt(parentBlock.header.gasLimit)
const gasLimit = utils.bufferToInt(this.gasLimit)
const a = Math.floor(pGasLimit / params.gasLimitBoundDivisor.v)
const maxGasLimit = pGasLimit + a
const minGasLimit = pGasLimit - a
const pGasLimit = new BN(parentBlock.header.gasLimit)
const gasLimit = new BN(this.gasLimit)
const a = pGasLimit.div(new BN(params.gasLimitBoundDivisor.v))
const maxGasLimit = pGasLimit.add(a)
const minGasLimit = pGasLimit.sub(a)

return maxGasLimit > gasLimit && minGasLimit < gasLimit && params.minGasLimit.v <= gasLimit
return gasLimit.lt(maxGasLimit) && gasLimit.gt(minGasLimit) && gasLimit.gte(params.minGasLimit.v)
}

/**
Expand Down

0 comments on commit b4f8033

Please sign in to comment.