[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 02/02: wallet-core: only schedule auto-refresh check
From: |
gnunet |
Subject: |
[taler-wallet-core] 02/02: wallet-core: only schedule auto-refresh check if exchange update has no last error |
Date: |
Tue, 31 May 2022 15:44:27 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
commit 59bc54422f3e9aa7a487705489f6755e02ff5c0a
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue May 31 15:44:22 2022 +0200
wallet-core: only schedule auto-refresh check if exchange update has no
last error
---
.../taler-wallet-core/src/operations/pending.ts | 18 ++++----
.../taler-wallet-core/src/operations/refresh.ts | 49 ++++++++++++++--------
2 files changed, 42 insertions(+), 25 deletions(-)
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 }),
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.