From 32396c1ad44200a036f859159477df18e5a015de Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 25 Nov 2014 15:20:44 -0300 Subject: [PATCH] index proposals in history for performace --- js/models/Wallet.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/models/Wallet.js b/js/models/Wallet.js index a3753431a..60a8b12c9 100644 --- a/js/models/Wallet.js +++ b/js/models/Wallet.js @@ -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;