diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-06 00:24:34 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-06 00:24:34 +0100 |
commit | 65bccbd139c53a2baccec442a680373125488102 (patch) | |
tree | 216860ec3523af33091b8fb52193787034c667f8 /src/wallet-impl/pending.ts | |
parent | 7b54439fd62bd2a5e15b3068a8fbaffeb0a57468 (diff) |
separate operations for pay, refund status query and refund submission
Diffstat (limited to 'src/wallet-impl/pending.ts')
-rw-r--r-- | src/wallet-impl/pending.ts | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/src/wallet-impl/pending.ts b/src/wallet-impl/pending.ts index c86ed6959..169c7e291 100644 --- a/src/wallet-impl/pending.ts +++ b/src/wallet-impl/pending.ts @@ -32,9 +32,7 @@ import { ReserveRecordStatus, CoinStatus, ProposalStatus, - PurchaseStatus, } from "../dbTypes"; -import { assertUnreachable } from "../util/assertUnreachable"; function updateRetryDelay( oldDelay: Duration, @@ -355,28 +353,54 @@ async function gatherPurchasePending( onlyDue: boolean = false, ): Promise<void> { await tx.iter(Stores.purchases).forEach((pr) => { - if (pr.status === PurchaseStatus.Dormant) { - return; + if (!pr.payFinished) { + resp.nextRetryDelay = updateRetryDelay( + resp.nextRetryDelay, + now, + pr.payRetryInfo.nextRetry, + ); + resp.pendingOperations.push({ + type: "pay", + givesLifeness: true, + isReplay: false, + proposalId: pr.proposalId, + retryInfo: pr.payRetryInfo, + lastError: pr.lastPayError, + }); } - resp.nextRetryDelay = updateRetryDelay( - resp.nextRetryDelay, - now, - pr.retryInfo.nextRetry, - ); - if (onlyDue && pr.retryInfo.nextRetry.t_ms > now.t_ms) { - return; + if (pr.refundStatusRequested) { + resp.nextRetryDelay = updateRetryDelay( + resp.nextRetryDelay, + now, + pr.refundStatusRetryInfo.nextRetry, + ); + resp.pendingOperations.push({ + type: "refund-query", + givesLifeness: true, + proposalId: pr.proposalId, + retryInfo: pr.refundStatusRetryInfo, + lastError: pr.lastRefundStatusError, + }); + } + const numRefundsPending = Object.keys(pr.refundsPending).length; + if (numRefundsPending > 0) { + const numRefundsDone = Object.keys(pr.refundsDone).length; + resp.nextRetryDelay = updateRetryDelay( + resp.nextRetryDelay, + now, + pr.refundApplyRetryInfo.nextRetry, + ); + resp.pendingOperations.push({ + type: "refund-apply", + numRefundsDone, + numRefundsPending, + givesLifeness: true, + proposalId: pr.proposalId, + retryInfo: pr.refundApplyRetryInfo, + lastError: pr.lastRefundApplyError, + }); } - resp.pendingOperations.push({ - type: "pay", - givesLifeness: true, - isReplay: false, - proposalId: pr.proposalId, - status: pr.status, - retryInfo: pr.retryInfo, - lastError: pr.lastError, - }); }); - } export async function getPendingOperations( |