aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/withdraw.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-06-18 17:41:09 +0200
committerFlorian Dold <florian@dold.me>2024-06-18 17:41:09 +0200
commit3913d0117bd034b5d7467eeed6b10c59dae90ce8 (patch)
treef265f12ac42ef40db8580103f6e19d86f7a3dab7 /packages/taler-wallet-core/src/withdraw.ts
parente925f1d904ab3d81ab59133d74f94bbff52cb95b (diff)
downloadwallet-core-3913d0117bd034b5d7467eeed6b10c59dae90ce8.tar.xz
wallet-core: round-robin waiting for long-polling
With dynamic long-poll timeout computation
Diffstat (limited to 'packages/taler-wallet-core/src/withdraw.ts')
-rw-r--r--packages/taler-wallet-core/src/withdraw.ts38
1 files changed, 24 insertions, 14 deletions
diff --git a/packages/taler-wallet-core/src/withdraw.ts b/packages/taler-wallet-core/src/withdraw.ts
index 2af8807cc..7ba69d2c1 100644
--- a/packages/taler-wallet-core/src/withdraw.ts
+++ b/packages/taler-wallet-core/src/withdraw.ts
@@ -45,7 +45,6 @@ import {
EddsaPrivateKeyString,
ExchangeBatchWithdrawRequest,
ExchangeListItem,
- ExchangeTosStatus,
ExchangeUpdateStatus,
ExchangeWireAccount,
ExchangeWithdrawBatchResponse,
@@ -1614,14 +1613,18 @@ async function processQueryReserve(
`reserves/${reservePub}`,
withdrawalGroup.exchangeBaseUrl,
);
- reserveUrl.searchParams.set("timeout_ms", "30000");
- logger.trace(`querying reserve status via ${reserveUrl.href}`);
-
- const resp = await wex.http.fetch(reserveUrl.href, {
- timeout: getReserveRequestTimeout(withdrawalGroup),
- cancellationToken: wex.cancellationToken,
- });
+ const resp = await wex.ws.runLongpollQueueing(
+ reserveUrl.hostname,
+ async (timeoutMs) => {
+ reserveUrl.searchParams.set("timeout_ms", `${timeoutMs}`);
+ logger.trace(`querying reserve status via ${reserveUrl.href}`);
+ return await wex.http.fetch(reserveUrl.href, {
+ timeout: getReserveRequestTimeout(withdrawalGroup),
+ cancellationToken: wex.cancellationToken,
+ });
+ },
+ );
logger.trace(`reserve status code: HTTP ${resp.status}`);
@@ -1760,12 +1763,19 @@ async function processWithdrawalGroupPendingKyc(
`kyc-check/${kycInfo.requirementRow}/${kycInfo.paytoHash}/${userType}`,
exchangeUrl,
);
- url.searchParams.set("timeout_ms", "30000");
- logger.info(`long-polling for withdrawal KYC status via ${url.href}`);
- const kycStatusRes = await wex.http.fetch(url.href, {
- method: "GET",
- cancellationToken: wex.cancellationToken,
- });
+
+ const kycStatusRes = await wex.ws.runLongpollQueueing(
+ url.hostname,
+ async (timeoutMs) => {
+ url.searchParams.set("timeout_ms", `${timeoutMs}`);
+ logger.info(`long-polling for withdrawal KYC status via ${url.href}`);
+ return await wex.http.fetch(url.href, {
+ method: "GET",
+ cancellationToken: wex.cancellationToken,
+ });
+ },
+ );
+
logger.info(`kyc long-polling response status: HTTP ${kycStatusRes.status}`);
if (
kycStatusRes.status === HttpStatusCode.Ok ||