diff options
author | Florian Dold <florian@dold.me> | 2021-01-18 23:35:41 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-01-18 23:35:41 +0100 |
commit | 5f3c02d31a223add55a32b20f4a289210cbb4f15 (patch) | |
tree | d91ded55692aea1294c0565328515f120559ab6a /packages/taler-wallet-core/src/operations/pending.ts | |
parent | f884193b1adf0861f710c6ab1bb94ea2073ade65 (diff) | |
download | wallet-core-5f3c02d31a223add55a32b20f4a289210cbb4f15.tar.xz |
implement deposits
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pending.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index cc693a49d..bae281937 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -445,6 +445,34 @@ async function gatherRecoupPending( }); } +async function gatherDepositPending( + tx: TransactionHandle<typeof Stores.depositGroups>, + now: Timestamp, + resp: PendingOperationsResponse, + onlyDue = false, +): Promise<void> { + await tx.iter(Stores.depositGroups).forEach((dg) => { + if (dg.timestampFinished) { + return; + } + resp.nextRetryDelay = updateRetryDelay( + resp.nextRetryDelay, + now, + dg.retryInfo.nextRetry, + ); + if (onlyDue && dg.retryInfo.nextRetry.t_ms > now.t_ms) { + return; + } + resp.pendingOperations.push({ + type: PendingOperationType.Deposit, + givesLifeness: true, + depositGroupId: dg.depositGroupId, + retryInfo: dg.retryInfo, + lastError: dg.lastError, + }); + }); +} + export async function getPendingOperations( ws: InternalWalletState, { onlyDue = false } = {}, @@ -462,6 +490,7 @@ export async function getPendingOperations( Stores.purchases, Stores.recoupGroups, Stores.planchets, + Stores.depositGroups, ], async (tx) => { const walletBalance = await getBalancesInsideTransaction(ws, tx); @@ -479,6 +508,7 @@ export async function getPendingOperations( await gatherTipPending(tx, now, resp, onlyDue); await gatherPurchasePending(tx, now, resp, onlyDue); await gatherRecoupPending(tx, now, resp, onlyDue); + await gatherDepositPending(tx, now, resp, onlyDue); return resp; }, ); |