index proposals in history for performace

This commit is contained in:
Matias Alejo Garcia 2014-11-25 15:20:44 -03:00
commit 32396c1ad4

View file

@ -2573,6 +2573,7 @@ Wallet.prototype.getTransactionHistory = function(opts, cb) {
var proposals = self.getTxProposals();
var satToUnit = 1 / self.settings.unitToSatoshi;
var indexedProposals = _.indexBy(proposal,'sentTxid');
function extractInsOuts(tx) {
@ -2664,10 +2665,7 @@ Wallet.prototype.getTransactionHistory = function(opts, cb) {
tx.amount = tx.amountSat * satToUnit;
tx.minedTs = !_.isNaN(tx.time) ? tx.time * 1000 : undefined;
var proposal = _.findWhere(proposals, {
sentTxid: tx.txid
});
var proposal = indexedProposals[tx.txid];
if (proposal) {
// TODO refactor
tx.comment = proposal.comment;