retry logic
This commit is contained in:
parent
cb531beaef
commit
7ae7475a7b
@ -637,16 +637,15 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private processPreCoin(preCoin): void {
|
private processPreCoin(preCoin, retryDelayMs = 100): void {
|
||||||
let retryDelayMs = 100;
|
|
||||||
this.withdrawExecute(preCoin)
|
this.withdrawExecute(preCoin)
|
||||||
.then((c) => this.storeCoin(c))
|
.then((c) => this.storeCoin(c))
|
||||||
.catch((e) => {
|
.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);
|
console.error(e);
|
||||||
setTimeout(() => this.processPreCoin(preCoin), retryDelayMs);
|
|
||||||
// exponential backoff truncated at one minute
|
// 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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user