lru: minor.

This commit is contained in:
Christopher Jeffrey 2016-10-23 13:35:16 -07:00
parent 233f0c5278
commit b98ca596d1
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 15 additions and 11 deletions

View File

@ -337,7 +337,7 @@ LRU.prototype.batch = function batch() {
}; };
/** /**
* Start the pending LRU batch. * Start the pending batch.
*/ */
LRU.prototype.start = function start() { LRU.prototype.start = function start() {
@ -346,16 +346,16 @@ LRU.prototype.start = function start() {
}; };
/** /**
* Clear the pending LRU batch. * Clear the pending batch.
*/ */
LRU.prototype.clear = function clear() { LRU.prototype.clear = function clear() {
assert(this.pending); assert(this.pending);
this.pending = this.batch(); this.pending.clear();
}; };
/** /**
* Drop the pending LRU batch. * Drop the pending batch.
*/ */
LRU.prototype.drop = function drop() { LRU.prototype.drop = function drop() {
@ -364,7 +364,7 @@ LRU.prototype.drop = function drop() {
}; };
/** /**
* Commit the pending LRU batch. * Commit the pending batch.
*/ */
LRU.prototype.commit = function commit() { LRU.prototype.commit = function commit() {
@ -374,7 +374,7 @@ LRU.prototype.commit = function commit() {
}; };
/** /**
* Push an item onto the pending LRU batch. * Push an item onto the pending batch.
* @param {String} key * @param {String} key
* @param {Object} value * @param {Object} value
*/ */
@ -385,7 +385,7 @@ LRU.prototype.push = function push(key, value) {
}; };
/** /**
* Push a removal onto the pending LRU batch. * Push a removal onto the pending batch.
* @param {String} key * @param {String} key
*/ */
@ -427,6 +427,10 @@ LRUBatch.prototype.remove = function remove(key) {
this.ops.push(new LRUOp(true, key)); this.ops.push(new LRUOp(true, key));
}; };
LRUBatch.prototype.clear = function clear() {
this.ops.length = 0;
};
LRUBatch.prototype.commit = function commit() { LRUBatch.prototype.commit = function commit() {
var i, op; var i, op;

View File

@ -1583,7 +1583,7 @@ WalletDB.prototype.addBlock = co(function* addBlock(entry, txs) {
if (entry.height <= this.height) { if (entry.height <= this.height) {
this.logger.warning('Node is connecting low blocks in wallet.'); this.logger.warning('Node is connecting low blocks in wallet.');
return; return 0;
} }
if (entry.height !== this.height + 1) if (entry.height !== this.height + 1)
@ -1610,7 +1610,7 @@ WalletDB.prototype._addBlock = co(function* addBlock(entry, txs) {
if (entry.height <= this.network.checkpoints.lastHeight) { if (entry.height <= this.network.checkpoints.lastHeight) {
block = WalletBlock.fromEntry(entry); block = WalletBlock.fromEntry(entry);
yield this.setBlock(block); yield this.setBlock(block);
return; return 0;
} }
} }
@ -1650,7 +1650,7 @@ WalletDB.prototype.removeBlock = co(function* removeBlock(entry) {
if (entry.height > this.height) { if (entry.height > this.height) {
this.logger.warning('Node is disconnecting high blocks in wallet.'); this.logger.warning('Node is disconnecting high blocks in wallet.');
return; return 0;
} }
if (entry.height !== this.height) if (entry.height !== this.height)
@ -1674,7 +1674,7 @@ WalletDB.prototype._removeBlock = co(function* removeBlock(entry) {
var i, tx, prev; var i, tx, prev;
if (!block) if (!block)
return; return 0;
prev = yield this.getBlock(entry.height - 1); prev = yield this.getBlock(entry.height - 1);
assert(prev); assert(prev);