diff options
author | Florian Dold <florian@dold.me> | 2023-11-15 23:41:02 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-11-15 23:41:09 +0100 |
commit | e4a1b373b018d7528828954ff8da96fe6b5f9728 (patch) | |
tree | bc922cb2fd206185dd5ccaf3f4fdd8ca7c047a67 /packages/taler-wallet-core/src/operations/refresh.ts | |
parent | 07ff0c5a3781ff683f68f9821e9c94e02359791a (diff) | |
download | wallet-core-e4a1b373b018d7528828954ff8da96fe6b5f9728.tar.xz |
wallet-core: remove bogus exception
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index 95aedbbd6..3afdd2d71 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -298,7 +298,7 @@ async function provideRefreshSession( const sessionSecretSeed = encodeCrock(getRandomBytes(64)); // Store refresh session for this coin in the database. - const newSession = await ws.db + const mySession = await ws.db .mktx((x) => [x.refreshGroups, x.coins, x.refreshSessions]) .runReadWrite(async (tx) => { const rg = await tx.refreshGroups.get(refreshGroupId); @@ -310,7 +310,7 @@ async function provideRefreshSession( coinIndex, ]); if (existingSession) { - return; + return existingSession; } const newSession: RefreshSessionRecord = { coinIndex, @@ -327,9 +327,9 @@ async function provideRefreshSession( return newSession; }); logger.trace( - `created refresh session for coin #${coinIndex} in ${refreshGroupId}`, + `found/created refresh session for coin #${coinIndex} in ${refreshGroupId}`, ); - return newSession; + return mySession; } function getRefreshRequestTimeout(rg: RefreshGroupRecord): Duration { @@ -918,11 +918,9 @@ async function processRefreshSession( refreshSession = await provideRefreshSession(ws, refreshGroupId, coinIndex); } if (!refreshSession) { - if (refreshGroup.statusPerCoin[coinIndex] !== RefreshCoinStatus.Finished) { - throw Error( - "BUG: refresh session was not created and coin not marked as finished", - ); - } + // We tried to create the refresh session, but didn't get a result back. + // This means that either the session is finished, or that creating + // one isn't necessary. return; } if (refreshSession.norevealIndex === undefined) { |