aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pending.ts
diff options
context:
space:
mode:
authorÖzgür Kesim <oec-taler@kesim.org>2023-08-31 13:12:06 +0200
committerÖzgür Kesim <oec-taler@kesim.org>2023-08-31 13:12:06 +0200
commit94cfcc875065f988815c31aaf8ebf36f75ac5983 (patch)
tree8389a638c67a3ae2d57fb354da1df6378e82113f /packages/taler-wallet-core/src/operations/pending.ts
parente02a4eb990c8c54662fbb658695312bdfce492e0 (diff)
parent79973a63dd31c0d84b677a2a1511b1dffc6218b8 (diff)
Merge branch 'master' into age-withdraw
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);
}