summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/refresh.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-06-10 16:32:37 +0200
committerFlorian Dold <florian@dold.me>2021-06-10 16:32:37 +0200
commit8ad36d89f55783c34043ee9ef37759cd94bcec7c (patch)
tree1e638b45e59ef50985f799b57590032a57ac7049 /packages/taler-wallet-core/src/operations/refresh.ts
parent7b7e3b4565169835ad04062d5c76ba655abd770a (diff)
downloadwallet-core-8ad36d89f55783c34043ee9ef37759cd94bcec7c.tar.gz
wallet-core-8ad36d89f55783c34043ee9ef37759cd94bcec7c.tar.bz2
wallet-core-8ad36d89f55783c34043ee9ef37759cd94bcec7c.zip
simplify pending transactions, make more tests pass again
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts30
1 files changed, 14 insertions, 16 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index 8d21e811d..21c92c1b7 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -32,6 +32,7 @@ import {
RefreshGroupId,
RefreshReason,
TalerErrorDetails,
+ timestampToIsoString,
} from "@gnu-taler/taler-util";
import { AmountJson, Amounts } from "@gnu-taler/taler-util";
import { amountToPretty } from "@gnu-taler/taler-util";
@@ -864,7 +865,12 @@ export async function autoRefresh(
ws: InternalWalletState,
exchangeBaseUrl: string,
): Promise<void> {
+ logger.info(`doing auto-refresh check for '${exchangeBaseUrl}'`);
await updateExchangeFromUrl(ws, exchangeBaseUrl, true);
+ let minCheckThreshold = timestampAddDuration(
+ getTimestampNow(),
+ durationFromSpec({ days: 1 }),
+ );
await ws.db
.mktx((x) => ({
coins: x.coins,
@@ -899,28 +905,20 @@ export async function autoRefresh(
const executeThreshold = getAutoRefreshExecuteThreshold(denom);
if (isTimestampExpired(executeThreshold)) {
refreshCoins.push(coin);
+ } else {
+ const checkThreshold = getAutoRefreshCheckThreshold(denom);
+ minCheckThreshold = timestampMin(minCheckThreshold, checkThreshold);
}
}
if (refreshCoins.length > 0) {
await createRefreshGroup(ws, tx, refreshCoins, RefreshReason.Scheduled);
}
-
- const denoms = await tx.denominations.indexes.byExchangeBaseUrl
- .iter(exchangeBaseUrl)
- .toArray();
- let minCheckThreshold = timestampAddDuration(
- getTimestampNow(),
- durationFromSpec({ days: 1 }),
+ logger.info(
+ `current wallet time: ${timestampToIsoString(getTimestampNow())}`,
+ );
+ logger.info(
+ `next refresh check at ${timestampToIsoString(minCheckThreshold)}`,
);
- for (const denom of denoms) {
- const checkThreshold = getAutoRefreshCheckThreshold(denom);
- const executeThreshold = getAutoRefreshExecuteThreshold(denom);
- if (isTimestampExpired(executeThreshold)) {
- // No need to consider this denomination, we already did an auto refresh check.
- continue;
- }
- minCheckThreshold = timestampMin(minCheckThreshold, checkThreshold);
- }
exchange.nextRefreshCheck = minCheckThreshold;
await tx.exchanges.put(exchange);
});