diff options
author | Florian Dold <florian@dold.me> | 2023-12-11 20:01:28 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-12-12 15:42:34 +0100 |
commit | e31f18b8f129adb9cbe33158297a9cff56a7143e (patch) | |
tree | fc960e069a08ca1924a79c154f5ced26db709348 /packages/taler-wallet-core/src/operations/pending.ts | |
parent | 055645e17aa9424f299aa04f686de7574ab437c7 (diff) | |
download | wallet-core-e31f18b8f129adb9cbe33158297a9cff56a7143e.tar.xz |
wallet-core: towards better DD48 support
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pending.ts | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index 282f84ad7..a9d6c5595 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -22,12 +22,17 @@ * Imports. */ import { GlobalIDB } from "@gnu-taler/idb-bridge"; -import { AbsoluteTime, TransactionRecordFilter } from "@gnu-taler/taler-util"; +import { + AbsoluteTime, + TalerErrorDetail, + TalerPreciseTimestamp, + TransactionRecordFilter, +} from "@gnu-taler/taler-util"; import { BackupProviderStateTag, + DbPreciseTimestamp, DepositElementStatus, DepositGroupRecord, - DepositOperationStatus, ExchangeEntryDbUpdateStatus, PeerPullCreditRecord, PeerPullDebitRecordStatus, @@ -48,7 +53,6 @@ import { RewardRecordStatus, WalletStoresV1, WithdrawalGroupRecord, - WithdrawalGroupStatus, depositOperationNonfinalStatusRange, timestampAbsoluteFromDb, timestampOptionalAbsoluteFromDb, @@ -94,18 +98,29 @@ async function gatherExchangePending( now: AbsoluteTime, resp: PendingOperationsResponse, ): Promise<void> { - // FIXME: We should do a range query here based on the update time - // and/or the entry state. + let timestampDue: DbPreciseTimestamp | undefined = undefined; await tx.exchanges.iter().forEachAsync(async (exch) => { switch (exch.updateStatus) { case ExchangeEntryDbUpdateStatus.Initial: case ExchangeEntryDbUpdateStatus.Suspended: - case ExchangeEntryDbUpdateStatus.Failed: return; } const opUpdateExchangeTag = TaskIdentifiers.forExchangeUpdate(exch); let opr = await tx.operationRetries.get(opUpdateExchangeTag); - const timestampDue = opr?.retryInfo.nextRetry ?? exch.nextRefreshCheckStamp; + + switch (exch.updateStatus) { + case ExchangeEntryDbUpdateStatus.Ready: + timestampDue = opr?.retryInfo.nextRetry ?? exch.nextRefreshCheckStamp; + break; + case ExchangeEntryDbUpdateStatus.ReadyUpdate: + case ExchangeEntryDbUpdateStatus.InitialUpdate: + case ExchangeEntryDbUpdateStatus.UnavailableUpdate: + timestampDue = + opr?.retryInfo.nextRetry ?? + timestampPreciseToDb(TalerPreciseTimestamp.now()); + break; + } + resp.pendingOperations.push({ type: PendingTaskType.ExchangeUpdate, ...getPendingCommon( |