From c660db82c12e08020661828f1d8383baa7ef0e02 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 7 Sep 2023 20:35:46 +0200 Subject: wallet-core: address DB FIXMEs, systematic state numbering --- .../taler-wallet-core/src/operations/pending.ts | 80 +++++++++++----------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/pending.ts') diff --git a/packages/taler-wallet-core/src/operations/pending.ts b/packages/taler-wallet-core/src/operations/pending.ts index e37e45c16..207e6ffda 100644 --- a/packages/taler-wallet-core/src/operations/pending.ts +++ b/packages/taler-wallet-core/src/operations/pending.ts @@ -26,11 +26,10 @@ import { WalletStoresV1, BackupProviderStateTag, RefreshCoinStatus, - OperationStatusRange, - PeerPushPaymentInitiationStatus, + PeerPushDebitStatus, PeerPullDebitRecordStatus, - PeerPushPaymentIncomingStatus, - PeerPullPaymentInitiationStatus, + PeerPushCreditStatus, + PeerPullPaymentCreditStatus, WithdrawalGroupStatus, RewardRecordStatus, DepositOperationStatus, @@ -39,13 +38,14 @@ import { DepositGroupRecord, RewardRecord, PurchaseRecord, - PeerPullPaymentInitiationRecord, + PeerPullCreditRecord, PeerPullPaymentIncomingRecord, - PeerPushPaymentInitiationRecord, + PeerPushDebitRecord, PeerPushPaymentIncomingRecord, RefundGroupRecord, RefundGroupStatus, ExchangeEntryDbUpdateStatus, + RefreshOperationStatus, } from "../db.js"; import { PendingOperationsResponse, @@ -136,8 +136,8 @@ export async function iterRecordsForRefresh( let refreshGroups: RefreshGroupRecord[]; if (filter.onlyState === "nonfinal") { const keyRange = GlobalIDB.KeyRange.bound( - OperationStatusRange.ACTIVE_START, - OperationStatusRange.ACTIVE_END, + RefreshOperationStatus.Pending, + RefreshOperationStatus.Suspended, ); refreshGroups = await tx.refreshGroups.indexes.byStatus.getAll(keyRange); } else { @@ -470,28 +470,28 @@ async function gatherBackupPending( export async function iterRecordsForPeerPullInitiation( tx: GetReadOnlyAccess<{ - peerPullPaymentInitiations: typeof WalletStoresV1.peerPullPaymentInitiations; + peerPullCredit: typeof WalletStoresV1.peerPullCredit; }>, filter: TransactionRecordFilter, - f: (r: PeerPullPaymentInitiationRecord) => Promise, + f: (r: PeerPullCreditRecord) => Promise, ): Promise { if (filter.onlyState === "nonfinal") { const keyRange = GlobalIDB.KeyRange.bound( - PeerPullPaymentInitiationStatus.PendingCreatePurse, - PeerPullPaymentInitiationStatus.AbortingDeletePurse, + PeerPullPaymentCreditStatus.PendingCreatePurse, + PeerPullPaymentCreditStatus.AbortingDeletePurse, ); - await tx.peerPullPaymentInitiations.indexes.byStatus + await tx.peerPullCredit.indexes.byStatus .iter(keyRange) .forEachAsync(f); } else { - await tx.peerPullPaymentInitiations.indexes.byStatus.iter().forEachAsync(f); + await tx.peerPullCredit.indexes.byStatus.iter().forEachAsync(f); } } async function gatherPeerPullInitiationPending( ws: InternalWalletState, tx: GetReadOnlyAccess<{ - peerPullPaymentInitiations: typeof WalletStoresV1.peerPullPaymentInitiations; + peerPullCredit: typeof WalletStoresV1.peerPullCredit; operationRetries: typeof WalletStoresV1.operationRetries; }>, now: AbsoluteTime, @@ -518,7 +518,7 @@ async function gatherPeerPullInitiationPending( export async function iterRecordsForPeerPullDebit( tx: GetReadOnlyAccess<{ - peerPullPaymentIncoming: typeof WalletStoresV1.peerPullPaymentIncoming; + peerPullDebit: typeof WalletStoresV1.peerPullDebit; }>, filter: TransactionRecordFilter, f: (r: PeerPullPaymentIncomingRecord) => Promise, @@ -528,18 +528,18 @@ export async function iterRecordsForPeerPullDebit( PeerPullDebitRecordStatus.PendingDeposit, PeerPullDebitRecordStatus.AbortingRefresh, ); - await tx.peerPullPaymentIncoming.indexes.byStatus + await tx.peerPullDebit.indexes.byStatus .iter(keyRange) .forEachAsync(f); } else { - await tx.peerPullPaymentIncoming.indexes.byStatus.iter().forEachAsync(f); + await tx.peerPullDebit.indexes.byStatus.iter().forEachAsync(f); } } async function gatherPeerPullDebitPending( ws: InternalWalletState, tx: GetReadOnlyAccess<{ - peerPullPaymentIncoming: typeof WalletStoresV1.peerPullPaymentIncoming; + peerPullDebit: typeof WalletStoresV1.peerPullDebit; operationRetries: typeof WalletStoresV1.operationRetries; }>, now: AbsoluteTime, @@ -558,7 +558,7 @@ async function gatherPeerPullDebitPending( ...getPendingCommon(ws, opId, timestampDue), givesLifeness: true, retryInfo: retryRecord?.retryInfo, - peerPullPaymentIncomingId: pi.peerPullPaymentIncomingId, + peerPullDebitId: pi.peerPullDebitId, }); }, ); @@ -566,28 +566,28 @@ async function gatherPeerPullDebitPending( export async function iterRecordsForPeerPushInitiation( tx: GetReadOnlyAccess<{ - peerPushPaymentInitiations: typeof WalletStoresV1.peerPushPaymentInitiations; + peerPushDebit: typeof WalletStoresV1.peerPushDebit; }>, filter: TransactionRecordFilter, - f: (r: PeerPushPaymentInitiationRecord) => Promise, + f: (r: PeerPushDebitRecord) => Promise, ): Promise { if (filter.onlyState === "nonfinal") { const keyRange = GlobalIDB.KeyRange.bound( - PeerPushPaymentInitiationStatus.PendingCreatePurse, - PeerPushPaymentInitiationStatus.AbortingRefresh, + PeerPushDebitStatus.PendingCreatePurse, + PeerPushDebitStatus.AbortingRefresh, ); - await tx.peerPushPaymentInitiations.indexes.byStatus + await tx.peerPushDebit.indexes.byStatus .iter(keyRange) .forEachAsync(f); } else { - await tx.peerPushPaymentInitiations.indexes.byStatus.iter().forEachAsync(f); + await tx.peerPushDebit.indexes.byStatus.iter().forEachAsync(f); } } async function gatherPeerPushInitiationPending( ws: InternalWalletState, tx: GetReadOnlyAccess<{ - peerPushPaymentInitiations: typeof WalletStoresV1.peerPushPaymentInitiations; + peerPushDebit: typeof WalletStoresV1.peerPushDebit; operationRetries: typeof WalletStoresV1.operationRetries; }>, now: AbsoluteTime, @@ -614,36 +614,36 @@ async function gatherPeerPushInitiationPending( export async function iterRecordsForPeerPushCredit( tx: GetReadOnlyAccess<{ - peerPushPaymentIncoming: typeof WalletStoresV1.peerPushPaymentIncoming; + peerPushCredit: typeof WalletStoresV1.peerPushCredit; }>, filter: TransactionRecordFilter, f: (r: PeerPushPaymentIncomingRecord) => Promise, ): Promise { if (filter.onlyState === "nonfinal") { const keyRange = GlobalIDB.KeyRange.bound( - PeerPushPaymentIncomingStatus.PendingMerge, - PeerPushPaymentIncomingStatus.PendingWithdrawing, + PeerPushCreditStatus.PendingMerge, + PeerPushCreditStatus.PendingWithdrawing, ); - await tx.peerPushPaymentIncoming.indexes.byStatus + await tx.peerPushCredit.indexes.byStatus .iter(keyRange) .forEachAsync(f); } else { - await tx.peerPushPaymentIncoming.indexes.byStatus.iter().forEachAsync(f); + await tx.peerPushCredit.indexes.byStatus.iter().forEachAsync(f); } } async function gatherPeerPushCreditPending( ws: InternalWalletState, tx: GetReadOnlyAccess<{ - peerPushPaymentIncoming: typeof WalletStoresV1.peerPushPaymentIncoming; + peerPushCredit: typeof WalletStoresV1.peerPushCredit; operationRetries: typeof WalletStoresV1.operationRetries; }>, now: AbsoluteTime, resp: PendingOperationsResponse, ): Promise { const keyRange = GlobalIDB.KeyRange.bound( - PeerPushPaymentIncomingStatus.PendingMerge, - PeerPushPaymentIncomingStatus.PendingWithdrawing, + PeerPushCreditStatus.PendingMerge, + PeerPushCreditStatus.PendingWithdrawing, ); await iterRecordsForPeerPushCredit( tx, @@ -658,7 +658,7 @@ async function gatherPeerPushCreditPending( ...getPendingCommon(ws, opId, timestampDue), givesLifeness: true, retryInfo: retryRecord?.retryInfo, - peerPushPaymentIncomingId: pi.peerPushPaymentIncomingId, + peerPushCreditId: pi.peerPushCreditId, }); }, ); @@ -682,10 +682,10 @@ export async function getPendingOperations( x.depositGroups, x.recoupGroups, x.operationRetries, - x.peerPullPaymentInitiations, - x.peerPushPaymentInitiations, - x.peerPullPaymentIncoming, - x.peerPushPaymentIncoming, + x.peerPullCredit, + x.peerPushDebit, + x.peerPullDebit, + x.peerPushCredit, ]) .runReadWrite(async (tx) => { const resp: PendingOperationsResponse = { -- cgit v1.2.3