From 300bf67414a2bdabe50e5dee48c0fac2da7ba699 Mon Sep 17 00:00:00 2001 From: Patrick Nagurny Date: Tue, 8 Sep 2015 14:12:45 -0400 Subject: [PATCH] add isMainChain to block --- lib/blocks.js | 5 +++-- test/blocks.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/blocks.js b/lib/blocks.js index 30892e7..6052269 100644 --- a/lib/blocks.js +++ b/lib/blocks.js @@ -27,6 +27,7 @@ BlockController.prototype.block = function(req, res, next, hash) { } var info = self.node.services.bitcoind.getBlockIndex(hash); + info.isMainChain = self.node.services.bitcoind.isMainChain(hash); req.block = self.transformBlock(block, info); next(); @@ -54,8 +55,8 @@ BlockController.prototype.transformBlock = function(block, info) { previousblockhash: blockObj.header.prevHash, nextblockhash: null, // placeholder reward: this.getBlockReward(info.height) / 1e8, - isMainChain: true // placeholder - } + isMainChain: info.isMainChain + }; }; /** diff --git a/test/blocks.js b/test/blocks.js index 77520f8..9ef0af6 100644 --- a/test/blocks.js +++ b/test/blocks.js @@ -76,7 +76,8 @@ describe('Blocks', function() { getBlock: sinon.stub().callsArgWith(1, null, bitcoreBlock), services: { bitcoind: { - getBlockIndex: sinon.stub().returns(blockIndexes['0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7']) + getBlockIndex: sinon.stub().returns(blockIndexes['0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7']), + isMainChain: sinon.stub().returns(true) }, db: { tip: {