chainentry: no network pointer.
This commit is contained in:
parent
ef4ab275da
commit
76ff5f814f
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var BN = require('bn.js');
|
var BN = require('bn.js');
|
||||||
var Network = require('../protocol/network');
|
|
||||||
var consensus = require('../protocol/consensus');
|
var consensus = require('../protocol/consensus');
|
||||||
var util = require('../utils/util');
|
var util = require('../utils/util');
|
||||||
var crypto = require('../crypto/crypto');
|
var crypto = require('../crypto/crypto');
|
||||||
@ -50,8 +49,6 @@ function ChainEntry(chain, options, prev) {
|
|||||||
return new ChainEntry(chain, options, prev);
|
return new ChainEntry(chain, options, prev);
|
||||||
|
|
||||||
this.chain = chain;
|
this.chain = chain;
|
||||||
this.network = chain ? chain.network : Network.primary;
|
|
||||||
|
|
||||||
this.hash = encoding.NULL_HASH;
|
this.hash = encoding.NULL_HASH;
|
||||||
this.version = 1;
|
this.version = 1;
|
||||||
this.prevBlock = encoding.NULL_HASH;
|
this.prevBlock = encoding.NULL_HASH;
|
||||||
@ -160,7 +157,7 @@ ChainEntry.prototype.getChainwork = function getChainwork(prev) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ChainEntry.prototype.isGenesis = function isGenesis() {
|
ChainEntry.prototype.isGenesis = function isGenesis() {
|
||||||
return this.hash === this.network.genesis.hash;
|
return this.hash === this.chain.network.genesis.hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,8 +170,8 @@ ChainEntry.prototype.isGenesis = function isGenesis() {
|
|||||||
|
|
||||||
ChainEntry.prototype.getRetargetAncestors = function getRetargetAncestors() {
|
ChainEntry.prototype.getRetargetAncestors = function getRetargetAncestors() {
|
||||||
var timespan = ChainEntry.MEDIAN_TIMESPAN;
|
var timespan = ChainEntry.MEDIAN_TIMESPAN;
|
||||||
var interval = this.network.pow.retargetInterval;
|
var interval = this.chain.network.pow.retargetInterval;
|
||||||
var reset = this.network.pow.difficultyReset;
|
var reset = this.chain.network.pow.difficultyReset;
|
||||||
var max = timespan;
|
var max = timespan;
|
||||||
|
|
||||||
if ((this.height + 1) % interval === 0 || reset)
|
if ((this.height + 1) % interval === 0 || reset)
|
||||||
@ -234,7 +231,7 @@ ChainEntry.prototype.isMainChain = co(function* isMainChain() {
|
|||||||
var entry;
|
var entry;
|
||||||
|
|
||||||
if (this.hash === this.chain.tip.hash
|
if (this.hash === this.chain.tip.hash
|
||||||
|| this.hash === this.network.genesis.hash) {
|
|| this.hash === this.chain.network.genesis.hash) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +354,7 @@ ChainEntry.prototype.getMedianTimeAsync = co(function* getMedianTimeAsync() {
|
|||||||
|
|
||||||
ChainEntry.prototype.isHistorical = function isHistorical() {
|
ChainEntry.prototype.isHistorical = function isHistorical() {
|
||||||
if (this.chain.options.useCheckpoints) {
|
if (this.chain.options.useCheckpoints) {
|
||||||
if (this.height + 1 <= this.network.checkpoints.lastHeight)
|
if (this.height + 1 <= this.chain.network.checkpoints.lastHeight)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -375,7 +372,7 @@ ChainEntry.prototype.hasUnknown = function hasUnknown() {
|
|||||||
if ((bits >>> 0) !== topBits)
|
if ((bits >>> 0) !== topBits)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (this.version & this.network.unknownBits) !== 0;
|
return (this.version & this.chain.network.unknownBits) !== 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user