|
@ -2778,26 +2778,47 @@ WalletService.prototype.getTxHistory = function(opts, cb) { |
|
|
var from = opts.skip || 0; |
|
|
var from = opts.skip || 0; |
|
|
var to = from + opts.limit; |
|
|
var to = from + opts.limit; |
|
|
|
|
|
|
|
|
async.parallel([ |
|
|
|
|
|
|
|
|
async.waterfall([ |
|
|
|
|
|
|
|
|
function(next) { |
|
|
function(next) { |
|
|
getNormalizedTxs(addresses, from, to, next); |
|
|
getNormalizedTxs(addresses, from, to, next); |
|
|
}, |
|
|
}, |
|
|
function(next) { |
|
|
function(txs, next) { |
|
|
self.storage.fetchTxs(self.walletId, {}, next); |
|
|
// Fetch all proposals in [t - 7 days, t + 1 day]
|
|
|
}, |
|
|
var minTs = _.min(txs.items, 'time').time - 7 * 24 * 3600; |
|
|
function(next) { |
|
|
var maxTs = _.max(txs.items, 'time').time + 1 * 24 * 3600; |
|
|
self.storage.fetchTxNotes(self.walletId, {}, next); |
|
|
|
|
|
|
|
|
async.parallel([ |
|
|
|
|
|
|
|
|
|
|
|
function(done) { |
|
|
|
|
|
self.storage.fetchTxs(self.walletId, { |
|
|
|
|
|
minTs: minTs, |
|
|
|
|
|
maxTs: maxTs |
|
|
|
|
|
}, done); |
|
|
|
|
|
}, |
|
|
|
|
|
function(done) { |
|
|
|
|
|
self.storage.fetchTxNotes(self.walletId, { |
|
|
|
|
|
minTs: minTs |
|
|
|
|
|
}, done); |
|
|
|
|
|
}, |
|
|
|
|
|
], function(err, res) { |
|
|
|
|
|
return next(err, { |
|
|
|
|
|
txs: txs, |
|
|
|
|
|
txps: res[0], |
|
|
|
|
|
notes: res[1] |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
}, |
|
|
}, |
|
|
], function(err, res) { |
|
|
], function(err, res) { |
|
|
if (err) return cb(err); |
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
|
var finalTxs = decorate(res[0].items, addresses, res[1], res[2]); |
|
|
var finalTxs = decorate(res.txs.items, addresses, res.txps, res.notes); |
|
|
|
|
|
|
|
|
if (res[0].fromCache) |
|
|
if (res.txs.fromCache) |
|
|
log.debug("History from cache for:", self.walletId, from, to); |
|
|
log.debug("History from cache for:", self.walletId, from, to); |
|
|
|
|
|
|
|
|
return cb(null, finalTxs, !!res[0].fromCache); |
|
|
return cb(null, finalTxs, !!res.txs.fromCache); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|