From e50cbc911c9f6ff253a5ccb8ecfa150f23a5816e Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 12 Aug 2016 02:20:46 -0700 Subject: [PATCH] txdb: remove updated event. --- lib/bcoin/http/server.js | 6 ------ lib/bcoin/txdb.js | 19 +++++++------------ lib/bcoin/walletdb.js | 4 ---- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/lib/bcoin/http/server.js b/lib/bcoin/http/server.js index 88a12c3c..66f62f25 100644 --- a/lib/bcoin/http/server.js +++ b/lib/bcoin/http/server.js @@ -980,12 +980,6 @@ HTTPServer.prototype._initIO = function _initIO() { self.server.io.to('!all').emit('wallet confirmed', id, details); }); - this.walletdb.on('updated', function(id, tx, details) { - details = details.toJSON(); - self.server.io.to(id).emit('wallet updated', details); - self.server.io.to('!all').emit('wallet updated', id, details); - }); - this.walletdb.on('balance', function(id, balance, details) { balance = { confirmed: utils.btc(balance.confirmed), diff --git a/lib/bcoin/txdb.js b/lib/bcoin/txdb.js index 52b0f988..f0377b0f 100644 --- a/lib/bcoin/txdb.js +++ b/lib/bcoin/txdb.js @@ -668,7 +668,6 @@ TXDB.prototype._resolveOrphans = function _resolveOrphans(tx, index, callback) { TXDB.prototype._add = function add(tx, info, callback) { var self = this; - var updated = false; var batch, hash, i, j, path, paths, id; if (tx.mutable) @@ -738,8 +737,6 @@ TXDB.prototype._add = function add(tx, info, callback) { return self._addOrphan(key, outpoint, next); } - updated = true; - for (j = 0; j < paths.length; j++) { path = paths[j]; id = path.id + '/' + path.account; @@ -794,8 +791,6 @@ TXDB.prototype._add = function add(tx, info, callback) { self.coinCache.set(key, coin); - updated = true; - next(); }); }, function(err) { @@ -814,12 +809,8 @@ TXDB.prototype._add = function add(tx, info, callback) { self.emit('tx', tx, info); - if (updated) { - if (tx.ts !== 0) - self.emit('confirmed', tx, info); - - self.emit('updated', tx, info); - } + if (tx.ts !== 0) + self.emit('confirmed', tx, info); return callback(null, true, info); }); @@ -1009,7 +1000,11 @@ TXDB.prototype._confirm = function _confirm(tx, info, callback) { // and remove pending flag to mark as confirmed. assert(tx.height >= 0); + // Save the original received time. + tx.ps = existing.ps; + batch = self.start(); + batch.put('t/' + hash, tx.toExtended()); batch.del('p/' + hash); @@ -1053,8 +1048,8 @@ TXDB.prototype._confirm = function _confirm(tx, info, callback) { return callback(err); } - self.emit('confirmed', tx, info); self.emit('tx', tx, info); + self.emit('confirmed', tx, info); self.commit(function(err) { if (err) diff --git a/lib/bcoin/walletdb.js b/lib/bcoin/walletdb.js index 4a545ed1..b1a1fca5 100644 --- a/lib/bcoin/walletdb.js +++ b/lib/bcoin/walletdb.js @@ -127,10 +127,6 @@ WalletDB.prototype._init = function _init() { this.tx.on('unconfirmed', function(tx, info) { handleEvent('unconfirmed', tx, info); }); - - this.tx.on('updated', function(tx, info) { - handleEvent('updated', tx, info); - }); }; /**