aboutsummaryrefslogtreecommitdiff
path: root/src/wallet-impl/withdraw.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-12-07 22:02:11 +0100
committerFlorian Dold <florian.dold@gmail.com>2019-12-07 22:02:11 +0100
commit396bb61db70f654599256e512bfec4c008ee8269 (patch)
treecfaba65d5d0c4782c7c64c28b68a41689cdbc07a /src/wallet-impl/withdraw.ts
parentb68b52e95c126e0d3b9788d6332c19144f9dc7e7 (diff)
downloadwallet-core-396bb61db70f654599256e512bfec4c008ee8269.tar.xz
reset retry counter when forcing operations
Diffstat (limited to 'src/wallet-impl/withdraw.ts')
-rw-r--r--src/wallet-impl/withdraw.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/wallet-impl/withdraw.ts b/src/wallet-impl/withdraw.ts
index 5d89f64a9..96055c9c5 100644
--- a/src/wallet-impl/withdraw.ts
+++ b/src/wallet-impl/withdraw.ts
@@ -45,6 +45,7 @@ import {
oneShotIterIndex,
oneShotGetIndexed,
runWithWriteTransaction,
+ oneShotMutate,
} from "../util/query";
import {
updateExchangeFromUrl,
@@ -516,20 +517,37 @@ async function incrementWithdrawalRetry(
export async function processWithdrawSession(
ws: InternalWalletState,
withdrawalSessionId: string,
+ forceNow: boolean = false,
): Promise<void> {
const onOpErr = (e: OperationError) =>
incrementWithdrawalRetry(ws, withdrawalSessionId, e);
await guardOperationException(
- () => processWithdrawSessionImpl(ws, withdrawalSessionId),
+ () => processWithdrawSessionImpl(ws, withdrawalSessionId, forceNow),
onOpErr,
);
}
-export async function processWithdrawSessionImpl(
+async function resetWithdrawSessionRetry(
ws: InternalWalletState,
withdrawalSessionId: string,
+) {
+ await oneShotMutate(ws.db, Stores.withdrawalSession, withdrawalSessionId, (x) => {
+ if (x.retryInfo.active) {
+ x.retryInfo = initRetryInfo();
+ }
+ return x;
+ });
+}
+
+async function processWithdrawSessionImpl(
+ ws: InternalWalletState,
+ withdrawalSessionId: string,
+ forceNow: boolean,
): Promise<void> {
logger.trace("processing withdraw session", withdrawalSessionId);
+ if (forceNow) {
+ await resetWithdrawSessionRetry(ws, withdrawalSessionId);
+ }
const withdrawalSession = await oneShotGet(
ws.db,
Stores.withdrawalSession,