diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-07 22:02:11 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-07 22:02:11 +0100 |
commit | 396bb61db70f654599256e512bfec4c008ee8269 (patch) | |
tree | cfaba65d5d0c4782c7c64c28b68a41689cdbc07a /src/wallet-impl/withdraw.ts | |
parent | b68b52e95c126e0d3b9788d6332c19144f9dc7e7 (diff) | |
download | wallet-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.ts | 22 |
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, |