aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/exchanges.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-03-14 18:31:30 +0100
committerFlorian Dold <florian@dold.me>2022-03-14 18:31:36 +0100
commit332745862e728dc5e79a424698b2736c4f2683bf (patch)
tree6617d10c145868741f751853261c9c126b6f580e /packages/taler-wallet-core/src/operations/exchanges.ts
parent9e7ee06ad1870339d011a0be27867cc36f94490d (diff)
downloadwallet-core-332745862e728dc5e79a424698b2736c4f2683bf.tar.xz
wallet: towards db-less benchmarking, some refactoring
Diffstat (limited to 'packages/taler-wallet-core/src/operations/exchanges.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/exchanges.ts34
1 files changed, 30 insertions, 4 deletions
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<ExchangeInfo> {
+ 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,