From 396bb61db70f654599256e512bfec4c008ee8269 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 7 Dec 2019 22:02:11 +0100 Subject: reset retry counter when forcing operations --- src/wallet-impl/tip.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/wallet-impl/tip.ts') 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 { 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 { + 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; -- cgit v1.2.3