Merge pull request #359 from pnagurny/feature/main-chain
add isMainChain to block
This commit is contained in:
commit
2ae1cdbec2
@ -27,6 +27,7 @@ BlockController.prototype.block = function(req, res, next, hash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var info = self.node.services.bitcoind.getBlockIndex(hash);
|
var info = self.node.services.bitcoind.getBlockIndex(hash);
|
||||||
|
info.isMainChain = self.node.services.bitcoind.isMainChain(hash);
|
||||||
|
|
||||||
req.block = self.transformBlock(block, info);
|
req.block = self.transformBlock(block, info);
|
||||||
next();
|
next();
|
||||||
@ -54,8 +55,8 @@ BlockController.prototype.transformBlock = function(block, info) {
|
|||||||
previousblockhash: blockObj.header.prevHash,
|
previousblockhash: blockObj.header.prevHash,
|
||||||
nextblockhash: null, // placeholder
|
nextblockhash: null, // placeholder
|
||||||
reward: this.getBlockReward(info.height) / 1e8,
|
reward: this.getBlockReward(info.height) / 1e8,
|
||||||
isMainChain: true // placeholder
|
isMainChain: info.isMainChain
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -74,7 +74,8 @@ describe('Blocks', function() {
|
|||||||
getBlock: sinon.stub().callsArgWith(1, null, bitcoreBlock),
|
getBlock: sinon.stub().callsArgWith(1, null, bitcoreBlock),
|
||||||
services: {
|
services: {
|
||||||
bitcoind: {
|
bitcoind: {
|
||||||
getBlockIndex: sinon.stub().returns(blockIndexes['0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7'])
|
getBlockIndex: sinon.stub().returns(blockIndexes['0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7']),
|
||||||
|
isMainChain: sinon.stub().returns(true)
|
||||||
},
|
},
|
||||||
db: {
|
db: {
|
||||||
tip: {
|
tip: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user