diff options
author | Florian Dold <florian@dold.me> | 2023-06-30 16:14:58 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-06-30 16:14:58 +0200 |
commit | d4ee96138774e8bc469f172bbb6276af89d6f240 (patch) | |
tree | eda5bc6833306727f711cc5aedd5f307fa8b1f67 /packages/taler-wallet-core/src/operations/refresh.ts | |
parent | 7523ffa9105f71a6a4c201d3ee46dbfccc929cea (diff) | |
download | wallet-core-d4ee96138774e8bc469f172bbb6276af89d6f240.tar.xz |
wallet-core: rename OperationAttempt->TaskRun, do not allow task result values anymore
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index c1a16badf..caa5f9c9f 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -89,8 +89,8 @@ import { constructTaskIdentifier, makeCoinAvailable, makeCoinsVisible, - OperationAttemptResult, - OperationAttemptResultType, + TaskRunResult, + TaskRunResultType, } from "./common.js"; import { updateExchangeFromUrl } from "./exchanges.js"; import { @@ -770,23 +770,17 @@ export async function processRefreshGroup( ws: InternalWalletState, refreshGroupId: string, options: Record<string, never> = {}, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { logger.info(`processing refresh group ${refreshGroupId}`); const refreshGroup = await ws.db .mktx((x) => [x.refreshGroups]) .runReadOnly(async (tx) => tx.refreshGroups.get(refreshGroupId)); if (!refreshGroup) { - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished() } if (refreshGroup.timestampFinished) { - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.finished(); } // Process refresh sessions of the group in parallel. logger.trace("processing refresh sessions for old coins"); @@ -823,14 +817,11 @@ export async function processRefreshGroup( logger.warn(`exception: ${e}`); } if (inShutdown) { - return { - type: OperationAttemptResultType.Pending, - result: undefined, - }; + return TaskRunResult.pending(); } if (errors.length > 0) { return { - type: OperationAttemptResultType.Error, + type: TaskRunResultType.Error, errorDetail: makeErrorDetail( TalerErrorCode.WALLET_REFRESH_GROUP_INCOMPLETE, { @@ -841,10 +832,7 @@ export async function processRefreshGroup( }; } - return { - type: OperationAttemptResultType.Finished, - result: undefined, - }; + return TaskRunResult.pending(); } async function processRefreshSession( @@ -1122,7 +1110,7 @@ function getAutoRefreshExecuteThreshold(d: DenominationRecord): AbsoluteTime { export async function autoRefresh( ws: InternalWalletState, exchangeBaseUrl: string, -): Promise<OperationAttemptResult> { +): Promise<TaskRunResult> { logger.info(`doing auto-refresh check for '${exchangeBaseUrl}'`); // We must make sure that the exchange is up-to-date so that @@ -1204,7 +1192,7 @@ export async function autoRefresh( AbsoluteTime.toPreciseTimestamp(minCheckThreshold); await tx.exchanges.put(exchange); }); - return OperationAttemptResult.finishedEmpty(); + return TaskRunResult.finished(); } export function computeRefreshTransactionState( |