Fixed reentrant event

This commit is contained in:
Ivan Socolsky 2014-09-05 12:03:50 -03:00
commit 48cbd01686

View file

@ -1549,6 +1549,8 @@ Wallet.prototype.removeTxWithSpentInputs = function(cb) {
if (inputs.length === 0)
return;
var proposalsChanged = false;
this.blockchain.getUnspent(this.getAddressesStr(), function(err, unspentList) {
if (err) return cb(err);
@ -1560,12 +1562,15 @@ Wallet.prototype.removeTxWithSpentInputs = function(cb) {
inputs.forEach(function (input) {
if (!input.unspent) {
proposalsChanged = true;
self.txProposals.deleteOne(input.ntxid);
}
});
self.emit('txProposalsUpdated');
self.store();
if (proposalsChanged) {
self.emit('txProposalsUpdated');
self.store();
}
cb(null);
});