From ffb5d4bd898fac426b2a164bb5e6bac99a9460e9 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 12 Dec 2019 08:34:18 -0500 Subject: [PATCH 1/3] Blossom activation reward adjustment --- lib/blocks.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/blocks.js b/lib/blocks.js index 3ba0e9f17..be8bad721 100644 --- a/lib/blocks.js +++ b/lib/blocks.js @@ -352,6 +352,12 @@ BlockController.prototype.getBlockReward = function(height) { return 0; } + // If we've actived blossom, cut the reward in half + // https://github.com/zcash/zips/blob/master/zip-0208.rst + if (height > 653600) { + subsidy /= 2; + + } // Subsidy is cut in half every 840,000 blocks which will occur approximately every 4 years. subsidy = subsidy.shrn(halvings); From ea4bb04bd95e6eb5d2f9ed4ea3d87fae95ee580d Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 12 Dec 2019 12:11:18 -0500 Subject: [PATCH 2/3] Try larrys patch --- lib/blocks.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/blocks.js b/lib/blocks.js index be8bad721..dab16e41e 100644 --- a/lib/blocks.js +++ b/lib/blocks.js @@ -135,7 +135,7 @@ BlockController.prototype.transformBlock = function(block, info) { confirmations: info.confirmations, previousblockhash: this._normalizePrevHash(blockObj.header.prevHash), nextblockhash: info.nextHash, - reward: this.getBlockReward(info.height) / 1e8, + reward: this.getBlockReward(info.height, isMainChain) / 1e8, isMainChain: (info.confirmations !== -1), poolInfo: this.getPoolInfo(block) }; @@ -330,7 +330,7 @@ BlockController.prototype.formatTimestamp = function(date) { return yyyy + '-' + (mm[1] ? mm : '0' + mm[0]) + '-' + (dd[1] ? dd : '0' + dd[0]); //padding }; -BlockController.prototype.getBlockReward = function(height) { +BlockController.prototype.getBlockReward = function(height, isMainChain) { var subsidy = new BN(12.5 * 1e8); // Mining slow start @@ -347,17 +347,24 @@ BlockController.prototype.getBlockReward = function(height) { } var halvings = Math.floor((height - (20000/2)) / 840000); + + // Adjust for Blossom (see zcash src/chainparams.cpp) + if (isMainChain) { // mainnet + if (height >= 653600) { + halvings++; + } + } else { // testnet + if (height >= 584000) { + halvings++; + } + } + // Force block reward to zero when right shift is undefined. if (halvings >= 64) { return 0; } - // If we've actived blossom, cut the reward in half - // https://github.com/zcash/zips/blob/master/zip-0208.rst - if (height > 653600) { - subsidy /= 2; - - } + // Subsidy is cut in half every 840,000 blocks which will occur approximately every 4 years. subsidy = subsidy.shrn(halvings); From fd70b87666b54cd92047128b49b758138e999354 Mon Sep 17 00:00:00 2001 From: Ben Wilson Date: Thu, 12 Dec 2019 12:17:48 -0500 Subject: [PATCH 3/3] FIx isMainChain --- lib/blocks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blocks.js b/lib/blocks.js index dab16e41e..a22e4c854 100644 --- a/lib/blocks.js +++ b/lib/blocks.js @@ -135,7 +135,7 @@ BlockController.prototype.transformBlock = function(block, info) { confirmations: info.confirmations, previousblockhash: this._normalizePrevHash(blockObj.header.prevHash), nextblockhash: info.nextHash, - reward: this.getBlockReward(info.height, isMainChain) / 1e8, + reward: this.getBlockReward(info.height, (info.confirmations !== -1)) / 1e8, isMainChain: (info.confirmations !== -1), poolInfo: this.getPoolInfo(block) };