mempool: logs for block adding/removing.

This commit is contained in:
Christopher Jeffrey 2016-12-14 14:04:26 -08:00
parent 854cdf1367
commit 40b3e56402
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -177,6 +177,7 @@ Mempool.prototype._addBlock = function addBlock(block, txs) {
if (!entry) {
this.removeOrphan(hash);
this.resolveOrphans(tx);
continue;
}
@ -192,6 +193,13 @@ Mempool.prototype._addBlock = function addBlock(block, txs) {
// We need to reset the rejects filter periodically.
// There may be a locktime in a TX that is now valid.
this.rejects.reset();
if (entries.length === 0)
return;
this.logger.debug(
'Removed %d txs from mempool for block %d.',
entries.length, block.height);
};
/**
@ -221,6 +229,7 @@ Mempool.prototype.removeBlock = co(function* removeBlock(block, txs) {
*/
Mempool.prototype._removeBlock = co(function* removeBlock(block, txs) {
var total = 0;
var i, tx, hash;
for (i = 1; i < txs.length; i++) {
@ -232,6 +241,7 @@ Mempool.prototype._removeBlock = co(function* removeBlock(block, txs) {
try {
yield this._addTX(tx);
total++;
} catch (e) {
this.emit('error', e);
continue;
@ -241,6 +251,13 @@ Mempool.prototype._removeBlock = co(function* removeBlock(block, txs) {
}
this.rejects.reset();
if (total === 0)
return;
this.logger.debug(
'Added %d txs back into the mempool for block %d.',
total, block.height);
});
/**
@ -1447,10 +1464,8 @@ Mempool.prototype.removeOrphan = function removeOrphan(hash) {
hashes.splice(j, 1);
if (hashes.length === 0) {
if (hashes.length === 0)
delete this.waiting[prev];
continue;
}
}
delete this.orphans[hash];