From 332745862e728dc5e79a424698b2736c4f2683bf Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 14 Mar 2022 18:31:30 +0100 Subject: wallet: towards db-less benchmarking, some refactoring --- .../taler-wallet-core/src/operations/exchanges.ts | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/exchanges.ts') diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index 9d4a56fff..2006b792f 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -43,6 +43,7 @@ import { codecForAny, DenominationPubKey, DenomKeyType, + ExchangeKeysJson, } from "@gnu-taler/taler-util"; import { decodeCrock, encodeCrock, hash } from "@gnu-taler/taler-util"; import { CryptoApi } from "../crypto/workers/cryptoApi.js"; @@ -292,12 +293,37 @@ async function validateWireInfo( }; } +export interface ExchangeInfo { + wire: ExchangeWireJson; + keys: ExchangeKeysDownloadResult; +} + +export async function downloadExchangeInfo( + exchangeBaseUrl: string, + http: HttpRequestLibrary, +): Promise { + const wireInfo = await downloadExchangeWireInfo( + exchangeBaseUrl, + http, + Duration.getForever(), + ); + const keysInfo = await downloadExchangeKeysInfo( + exchangeBaseUrl, + http, + Duration.getForever(), + ); + return { + keys: keysInfo, + wire: wireInfo, + }; +} + /** * Fetch wire information for an exchange. * * @param exchangeBaseUrl Exchange base URL, assumed to be already normalized. */ -async function downloadExchangeWithWireInfo( +async function downloadExchangeWireInfo( exchangeBaseUrl: string, http: HttpRequestLibrary, timeout: Duration, @@ -374,7 +400,7 @@ interface ExchangeKeysDownloadResult { /** * Download and validate an exchange's /keys data. */ -async function downloadKeysInfo( +async function downloadExchangeKeysInfo( baseUrl: string, http: HttpRequestLibrary, timeout: Duration, @@ -526,10 +552,10 @@ async function updateExchangeFromUrlImpl( const timeout = getExchangeRequestTimeout(); - const keysInfo = await downloadKeysInfo(baseUrl, ws.http, timeout); + const keysInfo = await downloadExchangeKeysInfo(baseUrl, ws.http, timeout); logger.info("updating exchange /wire info"); - const wireInfoDownload = await downloadExchangeWithWireInfo( + const wireInfoDownload = await downloadExchangeWireInfo( baseUrl, ws.http, timeout, -- cgit v1.2.3