cache window.

This commit is contained in:
Christopher Jeffrey 2016-04-21 14:17:51 -07:00
parent dbf21b2538
commit 51a39c3a52
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 13 additions and 13 deletions

View File

@ -1103,7 +1103,7 @@ Chain.prototype.disconnect = function disconnect(entry, callback) {
* Connect an entry to the chain (updates the tip). * Connect an entry to the chain (updates the tip).
* This will do contextual-verification on the block * This will do contextual-verification on the block
* (necessary because we cannot validate the inputs * (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 {ChainBlock} entry
* @param {Function} callback * @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 * Set the best chain. This is called on every valid block
* that comes in. It may add and connect the block (main chain), * 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). * reorganize the chain (a higher fork).
* @private * @private
* @param {ChainBlock} entry * @param {ChainBlock} entry
@ -1531,7 +1531,7 @@ Chain.prototype.add = function add(block, callback, force) {
height: height height: height
}, prev); }, 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 // chainwork is less than or equal to
// our tip's. Add the block but do _not_ // our tip's. Add the block but do _not_
// connect the inputs. // connect the inputs.

View File

@ -57,17 +57,17 @@ function ChainDB(chain, options) {
this.loaded = false; this.loaded = false;
// Need to cache up to the retarget interval // We want at least 1 retarget interval cached
// if we're going to be checking the damn // for retargetting, but we need at least two
// target all the time. // cached for optimal versionbits state checks.
if (network.pow.allowMinDifficultyBlocks) // We add a padding of 100 for forked chains,
this._cacheWindow = network.pow.retargetInterval + 1; // reorgs, chain locator creation and the bip34
else // check.
this._cacheWindow = network.block.majorityWindow + 1; this.cacheWindow = (network.pow.retargetInterval + 1) * 2 + 100;
this.coinCache = new NullCache(100000); this.coinCache = new NullCache(100000);
this.cacheHash = new bcoin.lru(this._cacheWindow); this.cacheHash = new bcoin.lru(this.cacheWindow);
this.cacheHeight = new bcoin.lru(this._cacheWindow); this.cacheHeight = new bcoin.lru(this.cacheWindow);
this._init(); this._init();
} }
@ -689,7 +689,7 @@ ChainDB.prototype.reset = function reset(block, callback) {
/** /**
* Test whether the chain contains a block in the * 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. * be tested if the lookup is done by hash.
* @param {Hash|Number} height - Hash or height. * @param {Hash|Number} height - Hash or height.
* @param {Function} callback - Returns [Error, Boolean]. * @param {Function} callback - Returns [Error, Boolean].