aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/pending.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-09-07 20:35:46 +0200
committerFlorian Dold <florian@dold.me>2023-09-08 00:12:52 +0200
commitc660db82c12e08020661828f1d8383baa7ef0e02 (patch)
tree655b3aa9cf91fae4a4b4052356b97a9b3b119376 /packages/taler-wallet-core/src/operations/pending.ts
parent33f2798004b1235eeb33a66d08bf22243f5ae566 (diff)
downloadwallet-core-c660db82c12e08020661828f1d8383baa7ef0e02.tar.xz
wallet-core: address DB FIXMEs, systematic state numbering
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pending.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/pending.ts80
1 files changed, 40 insertions, 40 deletions
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<void>,
+ f: (r: PeerPullCreditRecord) => Promise<void>,
): Promise<void> {
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<void>,
@@ -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<void>,
+ f: (r: PeerPushDebitRecord) => Promise<void>,
): Promise<void> {
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<void>,
): Promise<void> {
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<void> {
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 = {