mempool: handle mined removal better.
This commit is contained in:
parent
8b05ef2def
commit
559cc3592d
@ -1612,11 +1612,13 @@ RPC.prototype.__template = co(function* _template(version, coinbase, rules) {
|
||||
}
|
||||
break;
|
||||
case constants.thresholdStates.ACTIVE:
|
||||
vbrules.push(name);
|
||||
if (rules) {
|
||||
if (rules.indexOf(name) === -1 && !deployment.force)
|
||||
throw new RPCError('Client must support ' + name + '.');
|
||||
}
|
||||
if (!deployment.force)
|
||||
name = '!' + name;
|
||||
vbrules.push(name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,7 +580,8 @@ HTTPServer.prototype._init = function _init() {
|
||||
|
||||
if (cmd.method !== 'getblocktemplate' && cmd.method !== 'getwork') {
|
||||
this.logger.debug('Handling RPC call : %s.', cmd.method);
|
||||
this.logger.debug(cmd.params);
|
||||
if (cmd.method !== 'submitblock')
|
||||
this.logger.debug(cmd.params);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@ -178,10 +178,12 @@ Mempool.prototype._addBlock = function addBlock(block, txs) {
|
||||
if (!entry) {
|
||||
this.removeOrphan(hash);
|
||||
this.resolveOrphans(tx);
|
||||
this.removeDoubleSpends(tx);
|
||||
continue;
|
||||
}
|
||||
|
||||
this.removeEntry(entry);
|
||||
this.removeDoubleSpends(tx);
|
||||
this.emit('confirmed', tx, block);
|
||||
|
||||
entries.push(entry);
|
||||
@ -1706,6 +1708,34 @@ Mempool.prototype.removeSpenders = function removeSpenders(entry) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Recursively remove double spenders
|
||||
* of a mined transaction's outpoints.
|
||||
* @private
|
||||
* @param {MempoolEntry} entry
|
||||
* @param {Boolean} limit
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
Mempool.prototype.removeDoubleSpends = function removeDoubleSpends(tx) {
|
||||
var i, input, prevout, spent;
|
||||
|
||||
for (i = 0; i < tx.inputs.length; i++) {
|
||||
input = tx.inputs[i];
|
||||
prevout = input.prevout;
|
||||
spent = this.getSpent(prevout.hash, prevout.index);
|
||||
|
||||
if (!spent)
|
||||
continue;
|
||||
|
||||
this.logger.debug(
|
||||
'Removing double spender from mempool: %s.',
|
||||
spent.tx.rhash());
|
||||
|
||||
this.removeEntry(spent, true);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the memory usage of a transaction.
|
||||
* Note that this only calculates the JS heap
|
||||
|
||||
Loading…
Reference in New Issue
Block a user