gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (defc393d -> 8929086e)


From: gnunet
Subject: [taler-wallet-core] branch master updated (defc393d -> 8929086e)
Date: Thu, 19 Aug 2021 16:06:15 +0200

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

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

    from defc393d add missing file
     new c0e6b6d0 run pending operations at least once, style fixes
     new 8929086e logging

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 packages/taler-util/src/logging.ts                 | 15 ++++++++++++
 packages/taler-wallet-cli/src/index.ts             |  1 +
 .../src/integrationtests/harness.ts                |  1 +
 .../test-timetravel-autorefresh.ts                 |  3 +++
 .../taler-wallet-core/src/operations/refresh.ts    | 28 +++++++++++++++++++++-
 .../taler-wallet-core/src/operations/withdraw.ts   | 18 +++++++-------
 packages/taler-wallet-core/src/wallet.ts           |  8 ++-----
 packages/taler-wallet-embedded/src/index.ts        |  2 +-
 .../taler-wallet-webextension/src/wxBackend.ts     | 12 ++++++----
 9 files changed, 66 insertions(+), 22 deletions(-)

diff --git a/packages/taler-util/src/logging.ts 
b/packages/taler-util/src/logging.ts
index 532174fd..0037d95a 100644
--- a/packages/taler-util/src/logging.ts
+++ b/packages/taler-util/src/logging.ts
@@ -56,6 +56,21 @@ function writeNodeLog(
 export class Logger {
   constructor(private tag: string) {}
 
+  shouldLogTrace() {
+    // FIXME: Implement logic to check loglevel
+    return true;
+  }
+
+  shouldLogInfo() {
+    // FIXME: Implement logic to check loglevel
+    return true;
+  }
+
+  shouldLogWarn() {
+    // FIXME: Implement logic to check loglevel
+    return true;
+  }
+
   info(message: string, ...args: any[]): void {
     if (isNode) {
       writeNodeLog(message, this.tag, "INFO", args);
diff --git a/packages/taler-wallet-cli/src/index.ts 
b/packages/taler-wallet-cli/src/index.ts
index 796b6ae1..68e42bd0 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -1065,5 +1065,6 @@ export function main() {
     logger.warn("Allowing withdrawal of late denominations for debugging");
     walletCoreDebugFlags.denomselAllowLate = true;
   }
+  logger.trace(`running wallet-cli with`, process.argv);
   walletCli.run();
 }
diff --git a/packages/taler-wallet-cli/src/integrationtests/harness.ts 
b/packages/taler-wallet-cli/src/integrationtests/harness.ts
index c9c576eb..305e46e5 100644
--- a/packages/taler-wallet-cli/src/integrationtests/harness.ts
+++ b/packages/taler-wallet-cli/src/integrationtests/harness.ts
@@ -1620,6 +1620,7 @@ export class WalletCli {
     const self = this;
     this._client = {
       async call(op: any, payload: any): Promise<any> {
+        console.log("calling wallet with timetravel arg", self.timetravelArg);
         const resp = await sh(
           self.globalTestState,
           `wallet-${self.name}`,
diff --git 
a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts 
b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
index bee7581b..bad82119 100644
--- 
a/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
+++ 
b/packages/taler-wallet-cli/src/integrationtests/test-timetravel-autorefresh.ts
@@ -62,6 +62,7 @@ async function applyTimeTravel(
   }
 
   if (s.wallet) {
+    console.log("setting wallet time travel to", timetravelDuration);
     s.wallet.setTimetravel(timetravelDuration);
   }
 }
@@ -139,6 +140,7 @@ export async function runTimetravelAutorefreshTest(t: 
GlobalTestState) {
 
   // Travel into the future, the deposit expiration is two years
   // into the future.
+  console.log("applying first time travel");
   await applyTimeTravel(durationFromSpec({ days: 400 }), {
     wallet,
     exchange,
@@ -164,6 +166,7 @@ export async function runTimetravelAutorefreshTest(t: 
GlobalTestState) {
 
   // Travel into the future, the deposit expiration is two years
   // into the future.
+  console.log("applying second time travel");
   await applyTimeTravel(durationFromSpec({ years: 2, months: 6 }), {
     wallet,
     exchange,
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts 
b/packages/taler-wallet-core/src/operations/refresh.ts
index 2549b140..2e6e7d80 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -31,6 +31,7 @@ import {
   NotificationType,
   RefreshGroupId,
   RefreshReason,
+  stringifyTimestamp,
   TalerErrorDetails,
   timestampToIsoString,
 } from "@gnu-taler/taler-util";
@@ -147,6 +148,9 @@ async function refreshCreateSession(
     throw Error("db inconsistent: exchange of coin not found");
   }
 
+  // FIXME: use helper functions from withdraw.ts
+  // to update and filter withdrawable denoms.
+
   const { availableAmount, availableDenoms } = await ws.db
     .mktx((x) => ({
       denominations: x.denominations,
@@ -161,6 +165,7 @@ async function refreshCreateSession(
         throw Error("db inconsistent: denomination for coin not found");
       }
 
+      // FIXME: use an index here, based on the withdrawal expiration time.
       const availableDenoms: DenominationRecord[] = await 
tx.denominations.indexes.byExchangeBaseUrl
         .iter(exchange.baseUrl)
         .toArray();
@@ -177,6 +182,19 @@ async function refreshCreateSession(
     availableDenoms,
   );
 
+  if (logger.shouldLogTrace()) {
+    logger.trace(`printing selected denominations for refresh`);
+    logger.trace(`current time: ${stringifyTimestamp(getTimestampNow())}`);
+    for (const denom of newCoinDenoms.selectedDenoms) {
+      console.log(`denom ${denom.denom}, count ${denom.count}`);
+      console.log(
+        `withdrawal expiration ${stringifyTimestamp(
+          denom.denom.stampExpireWithdraw,
+        )}`,
+      );
+    }
+  }
+
   if (newCoinDenoms.selectedDenoms.length === 0) {
     logger.trace(
       `not refreshing, available amount ${amountToPretty(
@@ -913,7 +931,15 @@ export async function autoRefresh(
         }
       }
       if (refreshCoins.length > 0) {
-        await createRefreshGroup(ws, tx, refreshCoins, 
RefreshReason.Scheduled);
+        const res = await createRefreshGroup(
+          ws,
+          tx,
+          refreshCoins,
+          RefreshReason.Scheduled,
+        );
+        logger.info(
+          `created refresh group for auto-refresh (${res.refreshGroupId})`,
+        );
       }
       logger.info(
         `current wallet time: ${timestampToIsoString(getTimestampNow())}`,
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts 
b/packages/taler-wallet-core/src/operations/withdraw.ts
index 44e62611..81c35c17 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -17,7 +17,6 @@
 /**
  * Imports.
  */
-import * as LibtoolVersion from "@gnu-taler/taler-util";
 import {
   AmountJson,
   Amounts,
@@ -41,6 +40,7 @@ import {
   WithdrawResponse,
   URL,
   WithdrawUriInfoResponse,
+  VersionMatchResult,
 } from "@gnu-taler/taler-util";
 import {
   CoinRecord,
@@ -143,7 +143,7 @@ interface ExchangeWithdrawDetails {
    *
    * Older exchanges don't return version information.
    */
-  versionMatch: LibtoolVersion.VersionMatchResult | undefined;
+  versionMatch: VersionMatchResult | undefined;
 
   /**
    * Libtool-style version string for the exchange or "unknown"
@@ -693,15 +693,15 @@ export async function updateWithdrawalDenoms(
   while (current < denominations.length) {
     const updatedDenominations: DenominationRecord[] = [];
     // Do a batch of batchSize
-    for (let batchIdx = 0; batchIdx < batchSize; batchIdx++) {
-      current++;
-      if (current >= denominations.length) {
-        break;
-      }
+    for (
+      let batchIdx = 0;
+      batchIdx < batchSize && current < denominations.length;
+      batchIdx++, current++
+    ) {
       const denom = denominations[current];
       if (denom.status === DenominationStatus.Unverified) {
         logger.trace(
-          `Validation denomination (${current + 1}/${
+          `Validating denomination (${current + 1}/${
             denominations.length
           }) signature of ${denom.denomPubHash}`,
         );
@@ -939,7 +939,7 @@ export async function getExchangeWithdrawalInfo(
 
   let versionMatch;
   if (exchangeDetails.protocolVersion) {
-    versionMatch = LibtoolVersion.compare(
+    versionMatch = compare(
       WALLET_EXCHANGE_PROTOCOL_VERSION,
       exchangeDetails.protocolVersion,
     );
diff --git a/packages/taler-wallet-core/src/wallet.ts 
b/packages/taler-wallet-core/src/wallet.ts
index 3c3da3ce..fec7e615 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -333,7 +333,7 @@ async function runTaskLoop(
       }
     }
 
-    if (opts.stopWhenDone && numGivingLiveness === 0) {
+    if (opts.stopWhenDone && numGivingLiveness === 0 && iteration !== 0) {
       logger.warn(`stopping, as no pending operations have lifeness`);
       return;
     }
@@ -970,15 +970,11 @@ export class Wallet {
     this.ws.stop();
   }
 
-  runRetryLoop(): Promise<void> {
-    return runTaskLoop(this.ws);
-  }
-
   runPending(forceNow: boolean = false) {
     return runPending(this.ws, forceNow);
   }
 
-  runTaskLoop(opts: RetryLoopOpts) {
+  runTaskLoop(opts?: RetryLoopOpts) {
     return runTaskLoop(this.ws, opts);
   }
 
diff --git a/packages/taler-wallet-embedded/src/index.ts 
b/packages/taler-wallet-embedded/src/index.ts
index 0dcfaad6..604375c7 100644
--- a/packages/taler-wallet-embedded/src/index.ts
+++ b/packages/taler-wallet-embedded/src/index.ts
@@ -179,7 +179,7 @@ class NativeWalletMessageHandler {
       const w = await getDefaultNodeWallet(this.walletArgs);
       this.maybeWallet = w;
       await w.handleCoreApiRequest("initWallet", "native-init", {});
-      w.runRetryLoop().catch((e) => {
+      w.runTaskLoop().catch((e) => {
         console.error("Error during wallet retry loop", e);
       });
       this.wp.resolve(w);
diff --git a/packages/taler-wallet-webextension/src/wxBackend.ts 
b/packages/taler-wallet-webextension/src/wxBackend.ts
index c41dd4fb..4004f04f 100644
--- a/packages/taler-wallet-webextension/src/wxBackend.ts
+++ b/packages/taler-wallet-webextension/src/wxBackend.ts
@@ -49,7 +49,7 @@ import { BrowserCryptoWorkerFactory } from 
"./browserCryptoWorkerFactory";
 /**
  * Currently active wallet instance.  Might be unloaded and
  * re-instantiated when the database is reset.
- * 
+ *
  * FIXME:  Maybe move the wallet resetting into the Wallet class?
  */
 let currentWallet: Wallet | undefined;
@@ -215,8 +215,10 @@ function makeSyncWalletRedirect(
 ): Record<string, unknown> {
   const innerUrl = new URL(chrome.extension.getURL(url));
   if (params) {
-    const hParams = Object.keys(params).map(k => `${k}=${params[k]}`).join('&')
-    innerUrl.hash = innerUrl.hash + '?' + hParams
+    const hParams = Object.keys(params)
+      .map((k) => `${k}=${params[k]}`)
+      .join("&");
+    innerUrl.hash = innerUrl.hash + "?" + hParams;
   }
   if (isFirefox()) {
     // Some platforms don't support the sync redirect (yet), so fall back to
@@ -272,8 +274,8 @@ async function reinitWallet(): Promise<void> {
       }
     }
   });
-  wallet.runRetryLoop().catch((e) => {
-    console.log("error during wallet retry loop", e);
+  wallet.runTaskLoop().catch((e) => {
+    console.log("error during wallet task loop", e);
   });
   // Useful for debugging in the background page.
   (window as any).talerWallet = wallet;

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