diff options
author | Florian Dold <florian@dold.me> | 2024-02-20 15:54:09 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-02-20 15:54:09 +0100 |
commit | 7ecd0b96bc18440209775605bd3e325465638e1a (patch) | |
tree | 42169bd7039d8de4de04c894e27f2e482b373044 /packages/taler-wallet-core | |
parent | df6f50028339c033982b94662e8ab465383095b3 (diff) | |
download | wallet-core-7ecd0b96bc18440209775605bd3e325465638e1a.tar.xz |
wallet-core: use long-polling in deposit tracking
Diffstat (limited to 'packages/taler-wallet-core')
-rw-r--r-- | packages/taler-wallet-core/src/deposits.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts index b327632d3..f532dc136 100644 --- a/packages/taler-wallet-core/src/deposits.ts +++ b/packages/taler-wallet-core/src/deposits.ts @@ -738,7 +738,7 @@ async function transitionToKycRequired( async function processDepositGroupPendingTrack( ws: InternalWalletState, depositGroup: DepositGroupRecord, - cancellationToken?: CancellationToken, + cancellationToken: CancellationToken, ): Promise<TaskRunResult> { const { depositGroupId } = depositGroup; for (let i = 0; i < depositGroup.statusPerCoin.length; i++) { @@ -767,6 +767,7 @@ async function processDepositGroupPendingTrack( depositGroup, coinPub, exchangeBaseUrl, + cancellationToken, ); if (track.type === "accepted") { @@ -888,8 +889,7 @@ async function processDepositGroupPendingTrack( }); return TaskRunResult.finished(); } else { - // FIXME: Use long-polling. - return TaskRunResult.backoff(); + return TaskRunResult.longpollReturnedPending(); } } @@ -1115,6 +1115,7 @@ async function trackDeposit( depositGroup: DepositGroupRecord, coinPub: string, exchangeUrl: string, + cancellationToken: CancellationToken, ): Promise<TrackTransaction> { const wireHash = hashWire( depositGroup.wire.payto_uri, @@ -1133,7 +1134,11 @@ async function trackDeposit( wireHash, }); url.searchParams.set("merchant_sig", sigResp.sig); - const httpResp = await ws.http.fetch(url.href, { method: "GET" }); + url.searchParams.set("timeout_ms", "30000"); + const httpResp = await ws.http.fetch(url.href, { + method: "GET", + cancellationToken, + }); logger.trace(`deposits response status: ${httpResp.status}`); switch (httpResp.status) { case HttpStatusCode.Accepted: { |