add history download retry if err

This commit is contained in:
Matias Alejo Garcia 2016-12-01 16:54:12 -03:00
parent 061e222184
commit 884ff75f5a
No known key found for this signature in database
GPG Key ID: 02470DB551277AB3
1 changed files with 10 additions and 1 deletions

View File

@ -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)));