cache window.
This commit is contained in:
parent
dbf21b2538
commit
51a39c3a52
@ -1103,7 +1103,7 @@ Chain.prototype.disconnect = function disconnect(entry, callback) {
|
||||
* Connect an entry to the chain (updates the tip).
|
||||
* This will do contextual-verification on the block
|
||||
* (necessary because we cannot validate the inputs
|
||||
* in side chains when they come in).
|
||||
* in alternate chains when they come in).
|
||||
* @param {ChainBlock} entry
|
||||
* @param {Function} callback
|
||||
*/
|
||||
@ -1159,7 +1159,7 @@ Chain.prototype.connect = function connect(entry, callback) {
|
||||
/**
|
||||
* Set the best chain. This is called on every valid block
|
||||
* that comes in. It may add and connect the block (main chain),
|
||||
* save the block without connection (side chain), or
|
||||
* save the block without connection (alternate chain), or
|
||||
* reorganize the chain (a higher fork).
|
||||
* @private
|
||||
* @param {ChainBlock} entry
|
||||
@ -1531,7 +1531,7 @@ Chain.prototype.add = function add(block, callback, force) {
|
||||
height: height
|
||||
}, prev);
|
||||
|
||||
// The block is on a side chain if the
|
||||
// The block is on a alternate chain if the
|
||||
// chainwork is less than or equal to
|
||||
// our tip's. Add the block but do _not_
|
||||
// connect the inputs.
|
||||
|
||||
@ -57,17 +57,17 @@ function ChainDB(chain, options) {
|
||||
|
||||
this.loaded = false;
|
||||
|
||||
// Need to cache up to the retarget interval
|
||||
// if we're going to be checking the damn
|
||||
// target all the time.
|
||||
if (network.pow.allowMinDifficultyBlocks)
|
||||
this._cacheWindow = network.pow.retargetInterval + 1;
|
||||
else
|
||||
this._cacheWindow = network.block.majorityWindow + 1;
|
||||
// We want at least 1 retarget interval cached
|
||||
// for retargetting, but we need at least two
|
||||
// cached for optimal versionbits state checks.
|
||||
// We add a padding of 100 for forked chains,
|
||||
// reorgs, chain locator creation and the bip34
|
||||
// check.
|
||||
this.cacheWindow = (network.pow.retargetInterval + 1) * 2 + 100;
|
||||
|
||||
this.coinCache = new NullCache(100000);
|
||||
this.cacheHash = new bcoin.lru(this._cacheWindow);
|
||||
this.cacheHeight = new bcoin.lru(this._cacheWindow);
|
||||
this.cacheHash = new bcoin.lru(this.cacheWindow);
|
||||
this.cacheHeight = new bcoin.lru(this.cacheWindow);
|
||||
|
||||
this._init();
|
||||
}
|
||||
@ -689,7 +689,7 @@ ChainDB.prototype.reset = function reset(block, callback) {
|
||||
|
||||
/**
|
||||
* Test whether the chain contains a block in the
|
||||
* main chain or side chain. Side chains will only
|
||||
* main chain or an alternate chain. Alternate chains will only
|
||||
* be tested if the lookup is done by hash.
|
||||
* @param {Hash|Number} height - Hash or height.
|
||||
* @param {Function} callback - Returns [Error, Boolean].
|
||||
|
||||
Loading…
Reference in New Issue
Block a user