diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-05-31 15:35:02 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-05-31 15:35:02 +0200 |
commit | 7ae7475a7b9a86914b43a90570eafc08ee6c11f0 (patch) | |
tree | 789a383b7fde245c1e4902df3e35f377bbf80e5c /lib/wallet/wallet.ts | |
parent | cb531beaef868dd75aa625e1f881a0304d7355c4 (diff) | |
download | wallet-core-7ae7475a7b9a86914b43a90570eafc08ee6c11f0.tar.xz |
retry logic
Diffstat (limited to 'lib/wallet/wallet.ts')
-rw-r--r-- | lib/wallet/wallet.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/wallet/wallet.ts b/lib/wallet/wallet.ts index a27a8f1a6..9d3799bde 100644 --- a/lib/wallet/wallet.ts +++ b/lib/wallet/wallet.ts @@ -637,16 +637,15 @@ export class Wallet { } - private processPreCoin(preCoin): void { - let retryDelayMs = 100; + private processPreCoin(preCoin, retryDelayMs = 100): void { this.withdrawExecute(preCoin) .then((c) => this.storeCoin(c)) .catch((e) => { - console.error("Failed to withdraw coin from precoin"); + console.error("Failed to withdraw coin from precoin, retrying in", retryDelayMs, "ms"); console.error(e); - setTimeout(() => this.processPreCoin(preCoin), retryDelayMs); // exponential backoff truncated at one minute - retryDelayMs = Math.min(retryDelayMs * 2, 1000 * 60); + let nextRetryDelayMs = Math.min(retryDelayMs * 2, 1000 * 60); + setTimeout(() => this.processPreCoin(preCoin, nextRetryDelayMs), retryDelayMs); }); } |