taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit f022e722d4d155a2ec21b2eb96a9ee8b253e45df
parent b623a7a8f3ec11488e31c194cf8f3a40471a0c67
Author: Florian Dold <florian@dold.me>
Date:   Wed, 18 Mar 2026 20:50:55 +0100

wallet-core: more DB cleanup

Diffstat:
Mpackages/taler-wallet-core/src/shepherd.ts | 13++++++-------
Mpackages/taler-wallet-core/src/wallet.ts | 18++++++++++++++++--
2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/packages/taler-wallet-core/src/shepherd.ts b/packages/taler-wallet-core/src/shepherd.ts @@ -333,8 +333,7 @@ export class TaskSchedulerImpl implements TaskScheduler { } async resetTaskRetries(taskId: TaskIdStr): Promise<void> { - const maybeNotification = await this.ws.db.runAllStoresReadWriteTx( - {}, + const maybeNotification = await this.ws.runStandaloneLegacyWalletDbTx( async (tx) => { logger.trace(`storing task [reset] for ${taskId}`); await tx.operationRetries.delete(taskId); @@ -500,7 +499,7 @@ async function storePendingTaskError( e: TalerErrorDetail, ): Promise<OperationRetryRecord> { logger.trace(`storing task [pending] with ERROR for ${pendingTaskId}`); - const res = await ws.db.runAllStoresReadWriteTx({}, async (tx) => { + const res = await ws.runStandaloneLegacyWalletDbTx(async (tx) => { let retryRecord = await tx.operationRetries.get(pendingTaskId); if (!retryRecord) { retryRecord = { @@ -532,7 +531,7 @@ async function storeTaskProgress( pendingTaskId: string, ): Promise<void> { logger.trace(`storing task [progress] for ${pendingTaskId}`); - await ws.db.runAllStoresReadWriteTx({}, async (tx) => { + await ws.runStandaloneLegacyWalletDbTx(async (tx) => { await tx.operationRetries.delete(pendingTaskId); }); } @@ -543,7 +542,7 @@ async function storePendingTaskPending( schedTime?: AbsoluteTime, ): Promise<OperationRetryRecord> { logger.trace(`storing task [pending] for ${pendingTaskId}`); - const res = await ws.db.runAllStoresReadWriteTx({}, async (tx) => { + const res = await ws.runStandaloneLegacyWalletDbTx(async (tx) => { let retryRecord = await tx.operationRetries.get(pendingTaskId); let hadError = false; if (!retryRecord) { @@ -589,7 +588,7 @@ async function storePendingTaskFinished( pendingTaskId: string, ): Promise<void> { logger.trace(`storing task [finished] for ${pendingTaskId}`); - await ws.db.runAllStoresReadWriteTx({}, async (tx) => { + await ws.runStandaloneLegacyWalletDbTx(async (tx) => { await tx.operationRetries.delete(pendingTaskId); }); } @@ -979,7 +978,7 @@ export async function getActiveTaskIds( const res: ActiveTaskIdsResult = { taskIds: [], }; - await ws.db.runAllStoresReadWriteTx({}, async (tx) => { + await ws.runStandaloneLegacyWalletDbTx(async (tx) => { const active = GlobalIDB.KeyRange.bound( OPERATION_STATUS_NONFINAL_FIRST, OPERATION_STATUS_NONFINAL_LAST, diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -3309,13 +3309,27 @@ export class InternalWalletState { } > = new Map(); - get db(): DbAccess<typeof WalletStoresV1> { + /** + * Run a database transaction outside of a wallet execution context. + */ + async runStandaloneLegacyWalletDbTx<T>( + f: ( + tx: WalletDbAllStoresReadWriteTransaction, + wtx: WalletDbTransaction, + ) => Promise<T>, + ): Promise<T> { if (!this._dbAccessHandle) { this._dbAccessHandle = this.createDbAccessHandle( CancellationToken.CONTINUE, ); } - return this._dbAccessHandle; + return await this._dbAccessHandle.runAllStoresReadWriteTx( + {}, + async (mytx) => { + const tx = new IdbWalletTransaction(mytx); + return await f(mytx, tx); + }, + ); } /**