chain: minor.
This commit is contained in:
parent
a085214d54
commit
a76442acde
@ -77,7 +77,7 @@ function Chain(options) {
|
|||||||
this.invalid = new LRU(100);
|
this.invalid = new LRU(100);
|
||||||
this.state = new DeploymentState();
|
this.state = new DeploymentState();
|
||||||
|
|
||||||
this.tip = null;
|
this.tip = new ChainEntry(this);
|
||||||
this.height = -1;
|
this.height = -1;
|
||||||
this.synced = false;
|
this.synced = false;
|
||||||
|
|
||||||
@ -1827,7 +1827,7 @@ Chain.prototype.maybeSync = function maybeSync() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Chain.prototype.hasChainwork = function hasChainwork() {
|
Chain.prototype.hasChainwork = function hasChainwork() {
|
||||||
return this.tip.chainwork.cmp(this.network.pow.chainwork) >= 0;
|
return this.tip.chainwork.gte(this.network.pow.chainwork);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1838,7 +1838,7 @@ Chain.prototype.hasChainwork = function hasChainwork() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Chain.prototype.hasCheckpoints = function hasCheckpoints() {
|
Chain.prototype.hasCheckpoints = function hasCheckpoints() {
|
||||||
return this.tip.chainwork.cmp(this.network.lastChainwork) >= 0;
|
return this.tip.chainwork.gte(this.network.lastChainwork);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -17,6 +17,7 @@ const BufferReader = require('../utils/reader');
|
|||||||
const StaticWriter = require('../utils/staticwriter');
|
const StaticWriter = require('../utils/staticwriter');
|
||||||
const Headers = require('../primitives/headers');
|
const Headers = require('../primitives/headers');
|
||||||
const InvItem = require('../primitives/invitem');
|
const InvItem = require('../primitives/invitem');
|
||||||
|
const ZERO = new BN(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an entry in the chain. Unlike
|
* Represents an entry in the chain. Unlike
|
||||||
@ -56,7 +57,7 @@ function ChainEntry(chain, options, prev) {
|
|||||||
this.bits = 0;
|
this.bits = 0;
|
||||||
this.nonce = 0;
|
this.nonce = 0;
|
||||||
this.height = -1;
|
this.height = -1;
|
||||||
this.chainwork = null;
|
this.chainwork = ZERO;
|
||||||
|
|
||||||
if (options)
|
if (options)
|
||||||
this.fromOptions(options, prev);
|
this.fromOptions(options, prev);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user