[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated (182439cf -> 59bc5442)
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated (182439cf -> 59bc5442) |
Date: |
Tue, 31 May 2022 15:44:25 +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 182439cf taler-config-lib: hooking into the build system
new 2e6f3b35 -error reporting, code formatting
new 59bc5442 wallet-core: only schedule auto-refresh check if exchange
update has no last error
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-wallet-cli/src/index.ts | 44 +++++++++++++------
packages/taler-wallet-core/src/errors.ts | 14 ++++++-
.../taler-wallet-core/src/operations/pending.ts | 18 ++++----
.../taler-wallet-core/src/operations/refresh.ts | 49 ++++++++++++++--------
packages/taler-wallet-core/src/wallet.ts | 2 +-
5 files changed, 87 insertions(+), 40 deletions(-)
diff --git a/packages/taler-wallet-cli/src/index.ts
b/packages/taler-wallet-cli/src/index.ts
index cec682b0..ebcee205 100644
--- a/packages/taler-wallet-cli/src/index.ts
+++ b/packages/taler-wallet-cli/src/index.ts
@@ -63,6 +63,7 @@ import {
SynchronousCryptoWorkerFactory,
nativeCrypto,
performanceNow,
+ summarizeTalerErrorDetail,
} from "@gnu-taler/taler-wallet-core";
import { lintExchangeDeployment } from "./lint.js";
import { runBench1 } from "./bench1.js";
@@ -237,11 +238,8 @@ async function withWallet<T>(
return ret;
} catch (e) {
const ed = getErrorDetailFromException(e);
- console.error("Operation failed: " + ed.message);
- console.error(
- "Error details:",
- JSON.stringify(ed.operationError, undefined, 2),
- );
+ console.error("Operation failed: " + summarizeTalerErrorDetail(ed));
+ console.error("Error details:", JSON.stringify(ed, undefined, 2));
process.exit(1);
} finally {
logger.info("operation with wallet finished, stopping");
@@ -1085,7 +1083,7 @@ testCli
.subcommand("withdrawTestkudos", "withdraw-testkudos")
.action(async (args) => {
await withWallet(args, async (wallet) => {
- wallet.client.call(WalletApiOperation.WithdrawTestkudos, {});
+ await wallet.client.call(WalletApiOperation.WithdrawTestkudos, {});
});
});
@@ -1114,7 +1112,7 @@ class PerfTimer {
stdev(nRuns: number) {
const m = this.tSum / BigInt(nRuns);
- const x = (this.tSumSq / BigInt(nRuns)) - m * m;
+ const x = this.tSumSq / BigInt(nRuns) - m * m;
return Math.floor(Math.sqrt(Number(x)));
}
}
@@ -1123,7 +1121,7 @@ testCli
.subcommand("benchmarkAgeRestrictions", "benchmark-age-restrictions")
.requiredOption("reps", ["--reps"], clk.INT, {
default: 100,
- help: "repetitions (default: 100)"
+ help: "repetitions (default: 100)",
})
.action(async (args) => {
const numReps = args.benchmarkAgeRestrictions.reps ?? 100;
@@ -1176,11 +1174,31 @@ testCli
}
}
- console.log(`edx25519-commit (ns): ${tCommit.mean(numReps)} (stdev
${tCommit.stdev(numReps)})`);
- console.log(`edx25519-attest (ns): ${tAttest.mean(numReps)} (stdev
${tAttest.stdev(numReps)})`);
- console.log(`edx25519-verify (ns): ${tVerify.mean(numReps)} (stdev
${tVerify.stdev(numReps)})`);
- console.log(`edx25519-derive (ns): ${tDerive.mean(numReps)} (stdev
${tDerive.stdev(numReps)})`);
- console.log(`edx25519-compare (ns): ${tCompare.mean(numReps)} (stdev
${tCompare.stdev(numReps)})`);
+ console.log(
+ `edx25519-commit (ns): ${tCommit.mean(numReps)} (stdev ${tCommit.stdev(
+ numReps,
+ )})`,
+ );
+ console.log(
+ `edx25519-attest (ns): ${tAttest.mean(numReps)} (stdev ${tAttest.stdev(
+ numReps,
+ )})`,
+ );
+ console.log(
+ `edx25519-verify (ns): ${tVerify.mean(numReps)} (stdev ${tVerify.stdev(
+ numReps,
+ )})`,
+ );
+ console.log(
+ `edx25519-derive (ns): ${tDerive.mean(numReps)} (stdev ${tDerive.stdev(
+ numReps,
+ )})`,
+ );
+ console.log(
+ `edx25519-compare (ns): ${tCompare.mean(numReps)} (stdev
${tCompare.stdev(
+ numReps,
+ )})`,
+ );
});
testCli.subcommand("logtest", "logtest").action(async (args) => {
diff --git a/packages/taler-wallet-core/src/errors.ts
b/packages/taler-wallet-core/src/errors.ts
index eda5444b..56017cc0 100644
--- a/packages/taler-wallet-core/src/errors.ts
+++ b/packages/taler-wallet-core/src/errors.ts
@@ -94,6 +94,11 @@ export function makePendingOperationFailedError(
});
}
+export function summarizeTalerErrorDetail(ed: TalerErrorDetail): string {
+ const errName = TalerErrorCode[ed.code] ?? "<unknown>";
+ return `Error (${ed.code}/${errName})`;
+}
+
export class TalerError<T = any> extends Error {
errorDetail: TalerErrorDetail & T;
private constructor(d: TalerErrorDetail & T) {
@@ -107,7 +112,14 @@ export class TalerError<T = any> extends Error {
detail: ErrBody<C>,
hint?: string,
): TalerError {
- // FIXME: include default hint?
+ if (!hint) {
+ const errName = TalerErrorCode[code];
+ if (errName) {
+ hint = `Error (${errName})`;
+ } else {
+ hint = `Error (<unknown>)`;
+ }
+ }
return new TalerError<unknown>({ code, hint, ...detail });
}
diff --git a/packages/taler-wallet-core/src/operations/pending.ts
b/packages/taler-wallet-core/src/operations/pending.ts
index b89c7c64..0a262d3b 100644
--- a/packages/taler-wallet-core/src/operations/pending.ts
+++ b/packages/taler-wallet-core/src/operations/pending.ts
@@ -57,14 +57,16 @@ async function gatherExchangePending(
lastError: e.lastError,
});
- resp.pendingOperations.push({
- type: PendingTaskType.ExchangeCheckRefresh,
- timestampDue:
- e.retryInfo?.nextRetry ??
- AbsoluteTime.fromTimestamp(e.nextRefreshCheck),
- givesLifeness: false,
- exchangeBaseUrl: e.baseUrl,
- });
+ // We only schedule a check for auto-refresh if the exchange update
+ // was successful.
+ if (!e.lastError) {
+ resp.pendingOperations.push({
+ type: PendingTaskType.ExchangeCheckRefresh,
+ timestampDue: AbsoluteTime.fromTimestamp(e.nextRefreshCheck),
+ givesLifeness: false,
+ exchangeBaseUrl: e.baseUrl,
+ });
+ }
});
}
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts
b/packages/taler-wallet-core/src/operations/refresh.ts
index 0dfcef42..fc90b608 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -15,26 +15,41 @@
*/
import {
- AbsoluteTime, AgeCommitment,
- AgeRestriction, AmountJson, Amounts, amountToPretty,
codecForExchangeMeltResponse,
+ AbsoluteTime,
+ AgeCommitment,
+ AgeRestriction,
+ AmountJson,
+ Amounts,
+ amountToPretty,
+ codecForExchangeMeltResponse,
codecForExchangeRevealResponse,
- CoinPublicKey, CoinPublicKeyString,
- DenomKeyType, Duration,
+ CoinPublicKey,
+ CoinPublicKeyString,
+ DenomKeyType,
+ Duration,
durationFromSpec,
- durationMul, encodeCrock,
+ durationMul,
+ encodeCrock,
ExchangeMeltRequest,
- ExchangeProtocolVersion, ExchangeRefreshRevealRequest, fnutil,
getRandomBytes,
+ ExchangeProtocolVersion,
+ ExchangeRefreshRevealRequest,
+ fnutil,
+ getRandomBytes,
HashCodeString,
HttpStatusCode,
- j2s, Logger, NotificationType,
+ j2s,
+ Logger,
+ NotificationType,
RefreshGroupId,
RefreshReason,
- TalerErrorDetail, TalerProtocolTimestamp, URL
+ TalerErrorDetail,
+ TalerProtocolTimestamp,
+ URL,
} from "@gnu-taler/taler-util";
import { TalerCryptoInterface } from "../crypto/cryptoImplementation.js";
import {
DerivedRefreshSession,
- RefreshNewDenomInfo
+ RefreshNewDenomInfo,
} from "../crypto/cryptoTypes.js";
import { CryptoApiStoppedError } from "../crypto/workers/cryptoDispatcher.js";
import {
@@ -45,28 +60,26 @@ import {
OperationStatus,
RefreshCoinStatus,
RefreshGroupRecord,
- WalletStoresV1
+ WalletStoresV1,
} from "../db.js";
import { TalerError } from "../errors.js";
import {
DenomInfo,
EXCHANGE_COINS_LOCK,
- InternalWalletState
+ InternalWalletState,
} from "../internal-wallet-state.js";
import {
readSuccessResponseJsonOrThrow,
- readUnexpectedResponseDetails
+ readUnexpectedResponseDetails,
} from "../util/http.js";
import { checkDbInvariant } from "../util/invariants.js";
import { GetReadWriteAccess } from "../util/query.js";
-import {
- RetryInfo
-} from "../util/retries.js";
+import { RetryInfo } from "../util/retries.js";
import { guardOperationException } from "./common.js";
import { updateExchangeFromUrl } from "./exchanges.js";
import {
isWithdrawableDenom,
- selectWithdrawalDenominations
+ selectWithdrawalDenominations,
} from "./withdraw.js";
const logger = new Logger("refresh.ts");
@@ -1023,10 +1036,12 @@ export async function autoRefresh(
): Promise<void> {
logger.info(`doing auto-refresh check for '${exchangeBaseUrl}'`);
- //updateExchangeFromUrl will also update retryInfo for this operation
+ // We must make sure that the exchange is up-to-date so that
+ // can refresh into new denominations.
await updateExchangeFromUrl(ws, exchangeBaseUrl, {
forceNow: true,
});
+
let minCheckThreshold = AbsoluteTime.addDuration(
AbsoluteTime.now(),
durationFromSpec({ days: 1 }),
diff --git a/packages/taler-wallet-core/src/wallet.ts
b/packages/taler-wallet-core/src/wallet.ts
index 689e45f3..a0eaca2e 100644
--- a/packages/taler-wallet-core/src/wallet.ts
+++ b/packages/taler-wallet-core/src/wallet.ts
@@ -296,7 +296,7 @@ export async function runPending(
} catch (e) {
if (e instanceof TalerError) {
console.error(
- "Operation failed:",
+ "Pending operation failed:",
JSON.stringify(e.errorDetail, undefined, 2),
);
} else {
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-wallet-core] branch master updated (182439cf -> 59bc5442),
gnunet <=