aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pending.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-08-30 15:54:56 +0200
committerFlorian Dold <florian@dold.me>2023-08-30 15:54:56 +0200
commitd19aef746c1e67deaccc7c8cefba008f2f0d46ca (patch)
tree26ee3734f6be8a418dc734761bdb48fc14dbafaf /packages/taler-wallet-core/src/operations/pending.ts
parent88f7338d7c84ac2a774b483ccff25faf6ceeb879 (diff)
wallet-core: towards DD48
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pending.ts28
1 files changed, 16 insertions, 12 deletions
diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts
index 6c6546f83..e37e45c16 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -45,6 +45,7 @@ import {
PeerPushPaymentIncomingRecord,
RefundGroupRecord,
RefundGroupStatus,
+ ExchangeEntryDbUpdateStatus,
} from "../db.js";
import {
PendingOperationsResponse,
@@ -81,19 +82,25 @@ async function gatherExchangePending(
ws: InternalWalletState,
tx: GetReadOnlyAccess<{
exchanges: typeof WalletStoresV1.exchanges;
- exchangeDetails: typeof WalletStoresV1.exchangeDetails;
operationRetries: typeof WalletStoresV1.operationRetries;
}>,
now: AbsoluteTime,
resp: PendingOperationsResponse,
): Promise<void> {
- // FIXME: We should do a range query here based on the update time.
+ // FIXME: We should do a range query here based on the update time
+ // and/or the entry state.
await tx.exchanges.iter().forEachAsync(async (exch) => {
+ switch (exch.updateStatus) {
+ case ExchangeEntryDbUpdateStatus.Initial:
+ case ExchangeEntryDbUpdateStatus.Suspended:
+ case ExchangeEntryDbUpdateStatus.Failed:
+ return;
+ }
const opTag = TaskIdentifiers.forExchangeUpdate(exch);
let opr = await tx.operationRetries.get(opTag);
const timestampDue =
opr?.retryInfo.nextRetry ??
- AbsoluteTime.fromPreciseTimestamp(exch.nextUpdate);
+ AbsoluteTime.fromStampMs(exch.nextUpdateStampMs);
resp.pendingOperations.push({
type: PendingTaskType.ExchangeUpdate,
...getPendingCommon(ws, opTag, timestampDue),
@@ -108,7 +115,7 @@ async function gatherExchangePending(
resp.pendingOperations.push({
type: PendingTaskType.ExchangeCheckRefresh,
...getPendingCommon(ws, opTag, timestampDue),
- timestampDue: AbsoluteTime.fromPreciseTimestamp(exch.nextRefreshCheck),
+ timestampDue: AbsoluteTime.fromStampMs(exch.nextRefreshCheckStampMs),
givesLifeness: false,
exchangeBaseUrl: exch.baseUrl,
});
@@ -184,8 +191,9 @@ export async function iterRecordsForWithdrawal(
WithdrawalGroupStatus.PendingRegisteringBank,
WithdrawalGroupStatus.PendingAml,
);
- withdrawalGroupRecords =
- await tx.withdrawalGroups.indexes.byStatus.getAll(range);
+ withdrawalGroupRecords = await tx.withdrawalGroups.indexes.byStatus.getAll(
+ range,
+ );
} else {
withdrawalGroupRecords =
await tx.withdrawalGroups.indexes.byStatus.getAll();
@@ -344,12 +352,8 @@ export async function iterRecordsForRefund(
f: (r: RefundGroupRecord) => Promise<void>,
): Promise<void> {
if (filter.onlyState === "nonfinal") {
- const keyRange = GlobalIDB.KeyRange.only(
- RefundGroupStatus.Pending
- );
- await tx.refundGroups.indexes.byStatus
- .iter(keyRange)
- .forEachAsync(f);
+ const keyRange = GlobalIDB.KeyRange.only(RefundGroupStatus.Pending);
+ await tx.refundGroups.indexes.byStatus.iter(keyRange).forEachAsync(f);
} else {
await tx.refundGroups.iter().forEachAsync(f);
}