From cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 26 May 2023 12:19:32 +0200 Subject: taler-util,wallet-core: implement TalerPreciseTimestamp Fixes #7703 --- .../taler-wallet-core/src/operations/exchanges.ts | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/exchanges.ts') diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts b/packages/taler-wallet-core/src/operations/exchanges.ts index d8fb95755..142e0cf03 100644 --- a/packages/taler-wallet-core/src/operations/exchanges.ts +++ b/packages/taler-wallet-core/src/operations/exchanges.ts @@ -43,6 +43,7 @@ import { Recoup, TalerError, TalerErrorCode, + TalerPreciseTimestamp, TalerProtocolDuration, TalerProtocolTimestamp, URL, @@ -229,7 +230,7 @@ export async function acceptExchangeTermsOfService( if (d) { d.tosAccepted = { etag: etag || d.tosCurrentEtag, - timestamp: TalerProtocolTimestamp.now(), + timestamp: TalerPreciseTimestamp.now(), }; await tx.exchangeDetails.put(d); } @@ -407,8 +408,8 @@ export async function provideExchangeRecordInTx( baseUrl: baseUrl, detailsPointer: undefined, lastUpdate: undefined, - nextUpdate: AbsoluteTime.toTimestamp(now), - nextRefreshCheck: AbsoluteTime.toTimestamp(now), + nextUpdate: AbsoluteTime.toPreciseTimestamp(now), + nextRefreshCheck: AbsoluteTime.toPreciseTimestamp(now), lastKeysEtag: undefined, lastWireEtag: undefined, }; @@ -497,7 +498,7 @@ async function downloadExchangeKeysInfo( protocolVersion: exchangeKeysJsonUnchecked.version, signingKeys: exchangeKeysJsonUnchecked.signkeys, reserveClosingDelay: exchangeKeysJsonUnchecked.reserve_closing_delay, - expiry: AbsoluteTime.toTimestamp( + expiry: AbsoluteTime.toProtocolTimestamp( getExpiry(resp, { minDuration: durationFromSpec({ hours: 1 }), }), @@ -601,7 +602,9 @@ export async function updateExchangeFromUrlHandler( if ( !forceNow && exchangeDetails !== undefined && - !AbsoluteTime.isExpired(AbsoluteTime.fromTimestamp(exchange.nextUpdate)) + !AbsoluteTime.isExpired( + AbsoluteTime.fromPreciseTimestamp(exchange.nextUpdate), + ) ) { logger.info("using existing exchange info"); return { @@ -724,15 +727,17 @@ export async function updateExchangeFromUrlHandler( if (existingDetails?.rowId) { newDetails.rowId = existingDetails.rowId; } - r.lastUpdate = TalerProtocolTimestamp.now(); - r.nextUpdate = keysInfo.expiry; + r.lastUpdate = TalerPreciseTimestamp.now(); + r.nextUpdate = AbsoluteTime.toPreciseTimestamp( + AbsoluteTime.fromProtocolTimestamp(keysInfo.expiry), + ); // New denominations might be available. - r.nextRefreshCheck = TalerProtocolTimestamp.now(); + r.nextRefreshCheck = TalerPreciseTimestamp.now(); if (detailsPointerChanged) { r.detailsPointer = { currency: newDetails.currency, masterPublicKey: newDetails.masterPublicKey, - updateClock: TalerProtocolTimestamp.now(), + updateClock: TalerPreciseTimestamp.now(), }; } await tx.exchanges.put(r); -- cgit v1.2.3