Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
Added Constantinople difficulty bomb delay
Browse files Browse the repository at this point in the history
  • Loading branch information
alextsg committed Sep 29, 2018
1 parent 2bda290 commit 76c4a5f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions header.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ BlockHeader.prototype.canonicalDifficulty = function (parentBlock) {
var dif

if (this._common.hardforkGteHardfork(hardfork, 'byzantium')) {
// max((2 if len(parent.uncles) else 1) - ((timestamp - parent.timestamp) // 9), -99)
// max((2 if len(parent.uncles) else 1) - ((timestamp - parent.timestamp) // 9), -99) (EIP100)
var uncleAddend = parentBlock.header.uncleHash.equals(utils.SHA3_RLP_ARRAY) ? 1 : 2
a = blockTs.sub(parentTs).idivn(9).ineg().iaddn(uncleAddend)
cutoff = new BN(-99)
Expand All @@ -125,8 +125,16 @@ BlockHeader.prototype.canonicalDifficulty = function (parentBlock) {
a = cutoff
}
dif = parentDif.add(offset.mul(a))
}

// Byzantium difficulty bomb delay
if (this._common.hardforkGteHardfork(hardfork, 'constantinople')) {
// Constantinople difficulty bomb delay (EIP1234)
num.isubn(5000000)
if (num.ltn(0)) {
num = new BN(0)
}
} else if (this._common.hardforkGteHardfork(hardfork, 'byzantium')) {
// Byzantium difficulty bomb delay (EIP649)
num.isubn(3000000)
if (num.ltn(0)) {
num = new BN(0)
Expand Down

0 comments on commit 76c4a5f

Please sign in to comment.