gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] 02/04: fixing high cpu usage after some time


From: gnunet
Subject: [taler-wallet-core] 02/04: fixing high cpu usage after some time
Date: Thu, 13 Jan 2022 05:34:28 +0100

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

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

commit f6ec105b72ab5b79b934b8a4c1626b019c31c4a2
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Thu Jan 13 01:31:53 2022 -0300

    fixing high cpu usage after some time
    
    retryinfo was not being updated and not being used by exchangeCheckRefresh 
pending operation
---
 packages/taler-wallet-core/src/operations/exchanges.ts | 13 +++++++------
 packages/taler-wallet-core/src/operations/pending.ts   | 11 ++---------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts 
b/packages/taler-wallet-core/src/operations/exchanges.ts
index 2975c860..c14f2765 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -123,7 +123,7 @@ async function handleExchangeUpdateError(
 ): Promise<void> {
   await ws.db
     .mktx((x) => ({ exchanges: x.exchanges }))
-    .runReadOnly(async (tx) => {
+    .runReadWrite(async (tx) => {
       const exchange = await tx.exchanges.get(baseUrl);
       if (!exchange) {
         return;
@@ -131,6 +131,7 @@ async function handleExchangeUpdateError(
       exchange.retryInfo.retryCounter++;
       updateRetryInfoTimeout(exchange.retryInfo);
       exchange.lastError = err;
+      await tx.exchanges.put(exchange)
     });
   if (err) {
     ws.notify({ type: NotificationType.ExchangeOperationError, error: err });
@@ -526,11 +527,11 @@ async function updateExchangeFromUrlImpl(
     tosFound !== undefined
       ? tosFound
       : await downloadExchangeWithTermsOfService(
-          baseUrl,
-          ws.http,
-          timeout,
-          "text/plain",
-        );
+        baseUrl,
+        ws.http,
+        timeout,
+        "text/plain",
+      );
 
   let recoupGroupId: string | undefined = undefined;
 
diff --git a/packages/taler-wallet-core/src/operations/pending.ts 
b/packages/taler-wallet-core/src/operations/pending.ts
index 99d27583..b2f13625 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -51,25 +51,18 @@ async function gatherExchangePending(
   resp: PendingOperationsResponse,
 ): Promise<void> {
   await tx.exchanges.iter().forEachAsync(async (e) => {
-    let exchangeUpdateTimestampDue: Timestamp;
-
-    if (e.lastError) {
-      exchangeUpdateTimestampDue = e.retryInfo.nextRetry;
-    } else {
-      exchangeUpdateTimestampDue = e.nextUpdate;
-    }
 
     resp.pendingOperations.push({
       type: PendingTaskType.ExchangeUpdate,
       givesLifeness: false,
-      timestampDue: exchangeUpdateTimestampDue,
+      timestampDue: e.lastError ? e.retryInfo.nextRetry : e.nextUpdate,
       exchangeBaseUrl: e.baseUrl,
       lastError: e.lastError,
     });
 
     resp.pendingOperations.push({
       type: PendingTaskType.ExchangeCheckRefresh,
-      timestampDue: e.nextRefreshCheck,
+      timestampDue: e.lastError ? e.retryInfo.nextRetry : e.nextRefreshCheck,
       givesLifeness: false,
       exchangeBaseUrl: e.baseUrl,
     });

-- 
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]