aboutsummaryrefslogtreecommitdiff
path: root/src/wallet-impl/tip.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/tip.ts
parentb68b52e95c126e0d3b9788d6332c19144f9dc7e7 (diff)
reset retry counter when forcing operations
Diffstat (limited to 'src/wallet-impl/tip.ts')
-rw-r--r--src/wallet-impl/tip.ts19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/wallet-impl/tip.ts b/src/wallet-impl/tip.ts
index 11e029fcd..e11eb3b42 100644
--- a/src/wallet-impl/tip.ts
+++ b/src/wallet-impl/tip.ts
@@ -128,15 +128,32 @@ async function incrementTipRetry(
export async function processTip(
ws: InternalWalletState,
tipId: string,
+ forceNow: boolean = false,
): Promise<void> {
const onOpErr = (e: OperationError) => incrementTipRetry(ws, tipId, e);
- await guardOperationException(() => processTipImpl(ws, tipId), onOpErr);
+ await guardOperationException(() => processTipImpl(ws, tipId, forceNow), onOpErr);
+}
+
+async function resetTipRetry(
+ ws: InternalWalletState,
+ tipId: string,
+): Promise<void> {
+ await oneShotMutate(ws.db, Stores.tips, tipId, (x) => {
+ if (x.retryInfo.active) {
+ x.retryInfo = initRetryInfo();
+ }
+ return x;
+ })
}
async function processTipImpl(
ws: InternalWalletState,
tipId: string,
+ forceNow: boolean,
) {
+ if (forceNow) {
+ await resetTipRetry(ws, tipId);
+ }
let tipRecord = await oneShotGet(ws.db, Stores.tips, tipId);
if (!tipRecord) {
return;