tx-pool: emit updates only at end of .add()
This commit is contained in:
parent
d4f11676c7
commit
af993dc66b
@ -60,6 +60,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
||||
this._all[hash] = tx;
|
||||
|
||||
var own = this._wallet.own(tx);
|
||||
var update = false;
|
||||
|
||||
// Consume unspent money or add orphans
|
||||
for (var i = 0; i < tx.inputs.length; i++) {
|
||||
@ -71,7 +72,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
||||
// Add TX to inputs and spend money
|
||||
tx.input(unspent.tx, unspent.index);
|
||||
delete this._unspent[key];
|
||||
this.emit('update');
|
||||
updated = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -83,10 +84,11 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
||||
this._orphans[key] = { tx: tx, index: input.out.index };
|
||||
}
|
||||
|
||||
if (!own)
|
||||
if (!own) {
|
||||
if (updated)
|
||||
this.emit('update', this._lastTs);
|
||||
return;
|
||||
|
||||
var updated = false;
|
||||
}
|
||||
|
||||
// Add unspent outputs or fullfill orphans
|
||||
for (var i = 0; i < tx.outputs.length; i++) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user