diff --git a/www/js/services/bma-services.js b/www/js/services/bma-services.js index 61e63d8c8f2730db11821108b49523ea698e9d56..88e981c7b3824fba4355ff4df44c529fd9bfd19d 100644 --- a/www/js/services/bma-services.js +++ b/www/js/services/bma-services.js @@ -293,10 +293,11 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. decrementGetPathCount(path, constants.LIMIT_REQUEST_DELAY - (Date.now() - start)); return res; }) - .catch(function (err) { + .catch(function(err) { decrementGetPathCount(path, constants.LIMIT_REQUEST_DELAY - (Date.now() - start)); // When too many request, retry in 3s if (err && err.ucode === errorCodes.HTTP_LIMITATION) { + // retry return $timeout(function () { return wrappedRequest(params); @@ -650,7 +651,7 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium. }); }, /*blocks: get('/tx/history/:pubkey/blocks/:from/:to', csCache.constants.LONG),*/ - pending: get('/tx/history/:pubkey/pending') + pending: getHighUsage('/tx/history/:pubkey/pending') } }, ud: { diff --git a/www/js/services/tx-services.js b/www/js/services/tx-services.js index b70c7b8967cbf4a6eb04dcd7213d4e1e1237a275..ad9aa288872c15ae4cbe641554c3c409296ec122 100644 --- a/www/js/services/tx-services.js +++ b/www/js/services/tx-services.js @@ -140,7 +140,6 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', }; var processedTxMap = {}; - var retryPendingCount = 0; var jobs = [ // get current block @@ -148,15 +147,6 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', // get pending tx BMA.tx.history.pending({pubkey: pubkey}) - .catch(function(err) { - if (err && err.ucode === BMA.errorCodes.HTTP_LIMITATION && retryPendingCount < 3) { - retryPendingCount++; - return $timeout(function() { - return BMA.tx.history.pending({pubkey: pubkey}); - }, 2000 * retryPendingCount); - } - throw err; - }) .then(function (res) { reduceTxAndPush(pubkey, res.history.sending, tx.pendings, processedTxMap, true /*allow pendings*/); reduceTxAndPush(pubkey, res.history.pending, tx.pendings, processedTxMap, true /*allow pendings*/); @@ -264,7 +254,7 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', } function addSources(result, sources) { - _(sources).forEach(function(src) { + _.forEach(sources, function(src) { addSource(src, result.sources, result.sourcesIndexByKey); }); } @@ -355,8 +345,9 @@ angular.module('cesium.tx.services', ['ngApi', 'cesium.bma.services', if (tx.sources) { addSources(data, tx.sources); } - delete tx.sources; - delete tx.inputs; + // DO NOT modify a cached data + //delete tx.sources; + //delete tx.inputs; balanceWithPending += tx.amount; // update balance txPendings.push(tx); diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index c257696b59bcf730c9efa4d6593697fb083d7b82..49b1b2ad9436e25028902ca3a21264b974ece1a4 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -133,7 +133,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se addSources = function(sources) { data.sources = data.sources || []; data.sourcesIndexByKey = data.sourcesIndexByKey || {}; - _(sources).forEach(function(src) { + _.forEach(sources, function(src) { addSource(src, data.sources, data.sourcesIndexByKey); }); }, @@ -727,7 +727,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se loadTxAndSources = function(fromTime) { // DEBUG - //console.debug('[wallet-service] Calling loadTxAndSources()'); + //console.debug('[wallet-service] Calling loadTxAndSources() from time ' + fromTime); if (fromTime === 'pending') { UIUtils.loading.update({template: "INFO.LOADING_PENDING_TX"});