wallet: emit updates with tx

This commit is contained in:
Fedor Indutny 2014-05-13 01:11:33 +04:00
parent 868e68be93
commit 2a6048f104
2 changed files with 4 additions and 3 deletions

View File

@ -100,7 +100,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
if (!own) {
if (updated)
this.emit('update', this._lastTs);
this.emit('update', this._lastTs, tx);
// Save spending TXs without adding unspents
if (this._storage && this._wallet.ownInput(tx))
@ -143,7 +143,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
this._lastTs = Math.max(tx.ts, this._lastTs);
if (updated)
this.emit('update', this._lastTs);
this.emit('update', this._lastTs, tx);
if (!noWrite)
this._storeTX(hash, tx);

View File

@ -54,10 +54,11 @@ Wallet.prototype._init = function init() {
// Notify owners about new accepted transactions
var self = this;
var prevBalance = null;
this.tx.on('update', function() {
this.tx.on('update', function(lastTs, tx) {
var b = this.balance();
if (prevBalance && prevBalance.cmp(b) !== 0)
self.emit('balance', b);
self.emit('update', tx);
prevBalance = b;
});