fix getChainwork.
This commit is contained in:
parent
7526beace0
commit
0d7929136a
@ -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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user