From 0bbc9763b2cfeb8738191732d13343b79d369545 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 10 Feb 2014 11:00:31 -0300 Subject: [PATCH] shows orphan status on block page --- lib/BlockDb.js | 15 ++++++++++++--- public/views/block.html | 4 +++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/BlockDb.js b/lib/BlockDb.js index c83cd4bf..004b9be0 100644 --- a/lib/BlockDb.js +++ b/lib/BlockDb.js @@ -139,6 +139,8 @@ function spec(b) { BlockDb.prototype.fromHashWithInfo = function(hash, cb) { + var self = this; + rpc.getBlock(hash, function(err, info) { // Not found? if (err && err.code === -5) return cb(); @@ -146,9 +148,16 @@ function spec(b) { if (info.result.height) info.result.reward = BitcoreBlock.getBlockValue(info.result.height) / util.COIN ; - return cb(null, { - hash: hash, - info: info.result, + + self.isMain(hash, function(err, val) { + if (err) return cb(err); + + info.result.isMainChain = val ? true : false; + + return cb(null, { + hash: hash, + info: info.result, + }); }); }); }; diff --git a/public/views/block.html b/public/views/block.html index 09646fd9..8a67400b 100644 --- a/public/views/block.html +++ b/public/views/block.html @@ -45,7 +45,9 @@ Height - {{block.height}} + {{block.height}} + (Mainchain) + (Orphaned) Block Reward