From e2f7bc79cd4326f769f370f230041101a099d98c Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 18 Aug 2020 18:23:06 +0530 Subject: introduce locking to avoid certain simultaneous requests to the exchange --- packages/taler-wallet-core/src/operations/pay.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/pay.ts') diff --git a/packages/taler-wallet-core/src/operations/pay.ts b/packages/taler-wallet-core/src/operations/pay.ts index c3dd6c6d3..996e1c1ec 100644 --- a/packages/taler-wallet-core/src/operations/pay.ts +++ b/packages/taler-wallet-core/src/operations/pay.ts @@ -57,7 +57,7 @@ import { Logger } from "../util/logging"; import { parsePayUri } from "../util/taleruri"; import { guardOperationException, OperationFailedError } from "./errors"; import { createRefreshGroup, getTotalRefreshCost } from "./refresh"; -import { InternalWalletState } from "./state"; +import { InternalWalletState, EXCHANGE_COINS_LOCK } from "./state"; import { getTimestampNow, timestampAddDuration } from "../util/time"; import { strcmp, canonicalJson } from "../util/helpers"; import { readSuccessResponseJsonOrThrow } from "../util/http"; @@ -796,7 +796,9 @@ export async function submitPay( logger.trace("making pay request", JSON.stringify(reqBody, undefined, 2)); - const resp = await ws.http.postJson(payUrl, reqBody); + const resp = await ws.runSequentialized([EXCHANGE_COINS_LOCK], () => + ws.http.postJson(payUrl, reqBody), + ); const merchantResp = await readSuccessResponseJsonOrThrow( resp, -- cgit v1.2.3