txdb: refactor.
This commit is contained in:
parent
f075767cdb
commit
3412916c89
@ -1260,26 +1260,31 @@ HTTPServer.prototype._initIO = function _initIO() {
|
||||
});
|
||||
|
||||
this.walletdb.on('tx', function(id, tx, details) {
|
||||
self.server.io.to(id).emit('wallet tx', details);
|
||||
self.server.io.to('!all').emit('wallet tx', id, details);
|
||||
var json = details.toJSON();
|
||||
self.server.io.to(id).emit('wallet tx', json);
|
||||
self.server.io.to('!all').emit('wallet tx', id, json);
|
||||
});
|
||||
|
||||
this.walletdb.on('confirmed', function(id, tx, details) {
|
||||
self.server.io.to(id).emit('wallet confirmed', details);
|
||||
self.server.io.to('!all').emit('wallet confirmed', id, details);
|
||||
var json = details.toJSON();
|
||||
self.server.io.to(id).emit('wallet confirmed', json);
|
||||
self.server.io.to('!all').emit('wallet confirmed', id, json);
|
||||
});
|
||||
|
||||
this.walletdb.on('unconfirmed', function(id, tx, details) {
|
||||
self.server.io.to(id).emit('wallet unconfirmed', details);
|
||||
self.server.io.to('!all').emit('wallet unconfirmed', id, details);
|
||||
var json = details.toJSON();
|
||||
self.server.io.to(id).emit('wallet unconfirmed', json);
|
||||
self.server.io.to('!all').emit('wallet unconfirmed', id, json);
|
||||
});
|
||||
|
||||
this.walletdb.on('conflict', function(id, tx, details) {
|
||||
self.server.io.to(id).emit('wallet conflict', details);
|
||||
self.server.io.to('!all').emit('wallet conflict', id, details);
|
||||
var json = details.toJSON();
|
||||
self.server.io.to(id).emit('wallet conflict', json);
|
||||
self.server.io.to('!all').emit('wallet conflict', id, json);
|
||||
});
|
||||
|
||||
this.walletdb.on('balance', function(id, balance) {
|
||||
var json = balance.toJSON();
|
||||
self.server.io.to(id).emit('wallet balance', json);
|
||||
self.server.io.to('!all').emit('wallet balance', id, json);
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -26,7 +26,6 @@ var HD = require('../hd/hd');
|
||||
var Account = require('./account');
|
||||
var MasterKey = require('./masterkey');
|
||||
var LRU = require('../utils/lru');
|
||||
var PathInfo = require('./pathinfo');
|
||||
|
||||
/**
|
||||
* BIP44 Wallet
|
||||
|
||||
@ -1234,9 +1234,13 @@ WalletDB.prototype.getWalletsByHashes = co(function* getWalletsByHashes(tx) {
|
||||
*/
|
||||
|
||||
WalletDB.prototype.getWalletsByInsert = co(function* getWalletsByInsert(tx) {
|
||||
var result = [];
|
||||
var hashes = tx.getOutputHashes('hex');
|
||||
var i, j, input, hash, wids;
|
||||
var i, j, result, hashes, input, hash, wids;
|
||||
|
||||
if (this.options.resolution)
|
||||
return yield this.getWalletsByHashes(tx);
|
||||
|
||||
result = [];
|
||||
hashes = tx.getOutputHashes('hex');
|
||||
|
||||
for (i = 0; i < tx.inputs.length; i++) {
|
||||
input = tx.inputs[i];
|
||||
|
||||
@ -19,6 +19,7 @@ describe('Chain', function() {
|
||||
node = new bcoin.fullnode({ db: 'memory' });
|
||||
chain = node.chain;
|
||||
walletdb = node.walletdb;
|
||||
walletdb.options.resolution = false;
|
||||
miner = node.miner;
|
||||
node.on('error', function() {});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user