wallet: emit updates with tx
This commit is contained in:
parent
868e68be93
commit
2a6048f104
@ -100,7 +100,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
|||||||
|
|
||||||
if (!own) {
|
if (!own) {
|
||||||
if (updated)
|
if (updated)
|
||||||
this.emit('update', this._lastTs);
|
this.emit('update', this._lastTs, tx);
|
||||||
|
|
||||||
// Save spending TXs without adding unspents
|
// Save spending TXs without adding unspents
|
||||||
if (this._storage && this._wallet.ownInput(tx))
|
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);
|
this._lastTs = Math.max(tx.ts, this._lastTs);
|
||||||
if (updated)
|
if (updated)
|
||||||
this.emit('update', this._lastTs);
|
this.emit('update', this._lastTs, tx);
|
||||||
|
|
||||||
if (!noWrite)
|
if (!noWrite)
|
||||||
this._storeTX(hash, tx);
|
this._storeTX(hash, tx);
|
||||||
|
|||||||
@ -54,10 +54,11 @@ Wallet.prototype._init = function init() {
|
|||||||
// Notify owners about new accepted transactions
|
// Notify owners about new accepted transactions
|
||||||
var self = this;
|
var self = this;
|
||||||
var prevBalance = null;
|
var prevBalance = null;
|
||||||
this.tx.on('update', function() {
|
this.tx.on('update', function(lastTs, tx) {
|
||||||
var b = this.balance();
|
var b = this.balance();
|
||||||
if (prevBalance && prevBalance.cmp(b) !== 0)
|
if (prevBalance && prevBalance.cmp(b) !== 0)
|
||||||
self.emit('balance', b);
|
self.emit('balance', b);
|
||||||
|
self.emit('update', tx);
|
||||||
prevBalance = b;
|
prevBalance = b;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user