From 0d7929136acb23364924b460a5ea805104aea2e1 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 23 Jan 2016 22:00:19 -0800 Subject: [PATCH] fix getChainwork. --- lib/bcoin/chain.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index 867a4f9b..65952b09 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -1163,18 +1163,15 @@ ChainBlock.prototype.__defineGetter__('next', function() { return this.chain.db.get(this.height + 1); }); -ChainBlock.prototype.__defineGetter__('proof', function() { +ChainBlock.prototype.getProof = function getProof() { var target = utils.fromCompact(this.bits); if (target.isNeg() || target.cmpn(0) === 0) return new bn(0); return new bn(1).ushln(256).div(target.addn(1)); -}); +}; ChainBlock.prototype.getChainwork = function() { - if (!this.prev) - return new bn(0); - - return (this.prev ? this.prev.chainwork : new bn(0)).add(this.proof); + return (this.prev ? this.prev.chainwork : new bn(0)).add(this.getProof()); }; ChainBlock.prototype.getMedianTime = function() {