diff options
author | Florian Dold <florian@dold.me> | 2023-12-12 21:24:21 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-12-12 21:24:28 +0100 |
commit | 387416f02dec4a7f948ba96e918e3cacaf92639e (patch) | |
tree | 959fde0a7f8c51c2749251ddff32588907e44f4b /packages/taler-wallet-core/src/operations/refresh.ts | |
parent | f7e01690b44e42b7088457374a2a8606fd94f84e (diff) | |
download | wallet-core-387416f02dec4a7f948ba96e918e3cacaf92639e.tar.xz |
wallet-core: implement maxExpirationDate for checkPeerPushDebit
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/refresh.ts | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts index 51dd9adac..e5bc3277d 100644 --- a/packages/taler-wallet-core/src/operations/refresh.ts +++ b/packages/taler-wallet-core/src/operations/refresh.ts @@ -50,6 +50,7 @@ import { TalerErrorCode, TalerErrorDetail, TalerPreciseTimestamp, + TalerProtocolTimestamp, TransactionAction, TransactionMajorState, TransactionState, @@ -1141,18 +1142,30 @@ function getAutoRefreshCheckThreshold(d: DenominationRecord): AbsoluteTime { /** * Timestamp after which the wallet would do an auto-refresh. */ -function getAutoRefreshExecuteThreshold(d: DenominationRecord): AbsoluteTime { +export function getAutoRefreshExecuteThreshold(d: { + stampExpireWithdraw: TalerProtocolTimestamp; + stampExpireDeposit: TalerProtocolTimestamp; +}): AbsoluteTime { const expireWithdraw = AbsoluteTime.fromProtocolTimestamp( - timestampProtocolFromDb(d.stampExpireWithdraw), + d.stampExpireWithdraw, ); const expireDeposit = AbsoluteTime.fromProtocolTimestamp( - timestampProtocolFromDb(d.stampExpireDeposit), + d.stampExpireDeposit, ); const delta = AbsoluteTime.difference(expireWithdraw, expireDeposit); const deltaDiv = durationMul(delta, 0.5); return AbsoluteTime.addDuration(expireWithdraw, deltaDiv); } +function getAutoRefreshExecuteThresholdForDenom( + d: DenominationRecord, +): AbsoluteTime { + return getAutoRefreshExecuteThreshold({ + stampExpireWithdraw: timestampProtocolFromDb(d.stampExpireWithdraw), + stampExpireDeposit: timestampProtocolFromDb(d.stampExpireDeposit), + }); +} + export async function autoRefresh( ws: InternalWalletState, exchangeBaseUrl: string, @@ -1196,7 +1209,7 @@ export async function autoRefresh( logger.warn("denomination not in database"); continue; } - const executeThreshold = getAutoRefreshExecuteThreshold(denom); + const executeThreshold = getAutoRefreshExecuteThresholdForDenom(denom); if (AbsoluteTime.isExpired(executeThreshold)) { refreshCoins.push({ coinPub: coin.coinPub, |