Merge pull request #5126 from matiu/bug/txhistory-cache

Bug/txhistory cache
This commit is contained in:
Gustavo Maximiliano Cortez 2016-12-02 10:52:33 -03:00 committed by GitHub
commit e5278df480
2 changed files with 12 additions and 2 deletions

View File

@ -36,6 +36,7 @@ bwcModule.provider("bwcService", function() {
var bwc = new Client({
baseUrl: opts.bwsurl || 'https://bws.bitpay.com/bws/api',
verbose: opts.verbose,
timeout: 100000,
transports: ['polling'],
});
if (walletData)

View File

@ -312,7 +312,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
return tx.txid != endingTxid;
});
return cb(null, res, res.length == limit);
return cb(null, res, res.length >= limit);
});
};
@ -403,7 +403,16 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
function getNewTxs(newTxs, skip, cb) {
getTxsFromServer(wallet, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
if (err) return cb(err);
if (err) {
$log.warn('BWS Error:' + err); //TODO
if (err instanceof errors.CONNECTION_ERROR || (err.message && err.message.match(/5../))) {
log.info('Retrying history download in 5 secs...');
return $timeout(function() {
return getNewTxs(newTxs, skip, cb);
}, 5000);
};
return cb(err);
}
newTxs = newTxs.concat(processNewTxs(wallet, lodash.compact(res)));