diff options
Diffstat (limited to 'packages')
-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) { |