gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: wallet-core: cache control wh


From: gnunet
Subject: [taler-wallet-core] branch master updated: wallet-core: cache control when force-reloading exchange entries
Date: Thu, 22 Feb 2024 13:49:05 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new 2e8a3596e wallet-core: cache control when force-reloading exchange 
entries
2e8a3596e is described below

commit 2e8a3596ea280f066da28bacccd077343192abea
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Feb 22 13:49:06 2024 +0100

    wallet-core: cache control when force-reloading exchange entries
---
 packages/taler-wallet-core/src/db.ts        |  6 ++++++
 packages/taler-wallet-core/src/exchanges.ts | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)

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
@@ -646,6 +646,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.
    */
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,

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]