mempool: logs for block adding/removing.
This commit is contained in:
parent
854cdf1367
commit
40b3e56402
@ -177,6 +177,7 @@ Mempool.prototype._addBlock = function addBlock(block, txs) {
|
|||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
this.removeOrphan(hash);
|
this.removeOrphan(hash);
|
||||||
|
this.resolveOrphans(tx);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,6 +193,13 @@ Mempool.prototype._addBlock = function addBlock(block, txs) {
|
|||||||
// We need to reset the rejects filter periodically.
|
// We need to reset the rejects filter periodically.
|
||||||
// There may be a locktime in a TX that is now valid.
|
// There may be a locktime in a TX that is now valid.
|
||||||
this.rejects.reset();
|
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) {
|
Mempool.prototype._removeBlock = co(function* removeBlock(block, txs) {
|
||||||
|
var total = 0;
|
||||||
var i, tx, hash;
|
var i, tx, hash;
|
||||||
|
|
||||||
for (i = 1; i < txs.length; i++) {
|
for (i = 1; i < txs.length; i++) {
|
||||||
@ -232,6 +241,7 @@ Mempool.prototype._removeBlock = co(function* removeBlock(block, txs) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
yield this._addTX(tx);
|
yield this._addTX(tx);
|
||||||
|
total++;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.emit('error', e);
|
this.emit('error', e);
|
||||||
continue;
|
continue;
|
||||||
@ -241,6 +251,13 @@ Mempool.prototype._removeBlock = co(function* removeBlock(block, txs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.rejects.reset();
|
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);
|
hashes.splice(j, 1);
|
||||||
|
|
||||||
if (hashes.length === 0) {
|
if (hashes.length === 0)
|
||||||
delete this.waiting[prev];
|
delete this.waiting[prev];
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this.orphans[hash];
|
delete this.orphans[hash];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user