From 9e96bc2188683cddd32d8258d226cbeaea4b0b99 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Mon, 12 May 2014 18:47:17 -0300 Subject: [PATCH] use new multiutxo insight call --- js/models/blockchain/Insight.js | 32 ++++++++++++++------------------ js/services/controllerUtils.js | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/js/models/blockchain/Insight.js b/js/models/blockchain/Insight.js index 7c6d3acc4..b4c307c27 100644 --- a/js/models/blockchain/Insight.js +++ b/js/models/blockchain/Insight.js @@ -114,26 +114,22 @@ Insight.prototype.getUnspent = function(addresses, cb) { var all = []; - _asyncForEach(addresses, function(addr, callback) { - var options = { - host: self.host, - port: self.port, - scheme: self.scheme, - method: 'GET', - path: '/api/addr/' + addr + '/utxo', + var options = { + host: self.host, + port: self.port, + scheme: self.scheme, + method: 'GET', + path: '/api/addrs/' + addresses.join(',') + '/utxo', - headers: { - 'Access-Control-Request-Headers': '' - } - }; + headers: { + 'Access-Control-Request-Headers': '' + } + }; - self._request(options, function(err, res) { - if (res && res.length > 0) { - all = all.concat(res); - } - callback(); - }); - }, function() { + self._request(options, function(err, res) { + if (res && res.length > 0) { + all = all.concat(res); + } return cb(all); }); }; diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 30d90a1be..3482da4e8 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -97,7 +97,6 @@ angular.module('copay.controllerUtils') }; root.updateBalance = function(cb) { - root.setSocketHandlers(); $rootScope.balanceByAddr = {}; var w = $rootScope.wallet; $rootScope.addrInfos = w.getAddressesInfo(); @@ -118,6 +117,7 @@ angular.module('copay.controllerUtils') $rootScope.loading = false; if (cb) cb(); }); + root.setSocketHandlers(); }; root.setSocketHandlers = function() {