summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/taler-wallet-core/src/db.ts6
-rw-r--r--packages/taler-wallet-core/src/exchanges.ts18
2 files changed, 24 insertions, 0 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts
index ab7a1562a..3a593a523 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -647,6 +647,12 @@ export interface ExchangeEntryRecord {
updateStatus: ExchangeEntryDbUpdateStatus;
/**
+ * If set to true, the next update to the exchange
+ * status will request /keys with no-cache headers set.
+ */
+ cachebreakNextUpdate?: boolean;
+
+ /**
* Etag of the current ToS of the exchange.
*/
tosCurrentEtag: string | undefined;
diff --git a/packages/taler-wallet-core/src/exchanges.ts b/packages/taler-wallet-core/src/exchanges.ts
index d17005705..3e38925c1 100644
--- a/packages/taler-wallet-core/src/exchanges.ts
+++ b/packages/taler-wallet-core/src/exchanges.ts
@@ -637,12 +637,18 @@ async function downloadExchangeKeysInfo(
http: HttpRequestLibrary,
timeout: Duration,
cancellationToken: CancellationToken,
+ noCache: boolean,
): Promise<ExchangeKeysDownloadResult> {
const keysUrl = new URL("keys", baseUrl);
+ const headers: Record<string, string> = {};
+ if (noCache) {
+ headers["cache-control"] = "no-cache";
+ }
const resp = await http.fetch(keysUrl.href, {
timeout,
cancellationToken,
+ headers,
});
logger.info("got response to /keys request");
@@ -871,10 +877,13 @@ async function startUpdateExchangeEntry(
const oldExchangeState = getExchangeState(r);
switch (r.updateStatus) {
case ExchangeEntryDbUpdateStatus.UnavailableUpdate:
+ r.cachebreakNextUpdate = options.forceUpdate;
break;
case ExchangeEntryDbUpdateStatus.Suspended:
+ r.cachebreakNextUpdate = options.forceUpdate;
break;
case ExchangeEntryDbUpdateStatus.ReadyUpdate:
+ r.cachebreakNextUpdate = options.forceUpdate;
break;
case ExchangeEntryDbUpdateStatus.Ready: {
const nextUpdateTimestamp = AbsoluteTime.fromPreciseTimestamp(
@@ -886,12 +895,17 @@ async function startUpdateExchangeEntry(
AbsoluteTime.isExpired(nextUpdateTimestamp)
) {
r.updateStatus = ExchangeEntryDbUpdateStatus.ReadyUpdate;
+ r.cachebreakNextUpdate = options.forceUpdate;
}
break;
}
case ExchangeEntryDbUpdateStatus.Initial:
+ r.cachebreakNextUpdate = options.forceUpdate;
r.updateStatus = ExchangeEntryDbUpdateStatus.InitialUpdate;
break;
+ case ExchangeEntryDbUpdateStatus.InitialUpdate:
+ r.cachebreakNextUpdate = options.forceUpdate;
+ break;
}
await tx.exchanges.put(r);
const newExchangeState = getExchangeState(r);
@@ -1216,6 +1230,7 @@ export async function updateExchangeFromUrlHandler(
ws.http,
timeout,
cancellationToken,
+ oldExchangeRec.cachebreakNextUpdate ?? false,
);
logger.trace("validating exchange wire info");
@@ -1346,7 +1361,9 @@ export async function updateExchangeFromUrlHandler(
};
}
r.updateStatus = ExchangeEntryDbUpdateStatus.Ready;
+ r.cachebreakNextUpdate = false;
await tx.exchanges.put(r);
+ logger.info(`putting new exchange details in DB: ${j2s(newDetails)}`);
const drRowId = await tx.exchangeDetails.put(newDetails);
checkDbInvariant(typeof drRowId.key === "number");
@@ -1685,6 +1702,7 @@ export async function downloadExchangeInfo(
http,
Duration.getForever(),
CancellationToken.CONTINUE,
+ false,
);
return {
keys: keysInfo,