summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/refresh.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-wallet-core/src/operations/refresh.ts')
-rw-r--r--packages/taler-wallet-core/src/operations/refresh.ts19
1 files changed, 10 insertions, 9 deletions
diff --git a/packages/taler-wallet-core/src/operations/refresh.ts b/packages/taler-wallet-core/src/operations/refresh.ts
index 14556f3c0..c46344313 100644
--- a/packages/taler-wallet-core/src/operations/refresh.ts
+++ b/packages/taler-wallet-core/src/operations/refresh.ts
@@ -48,6 +48,7 @@ import {
RefreshReason,
TalerErrorCode,
TalerErrorDetail,
+ TalerPreciseTimestamp,
TalerProtocolTimestamp,
TransactionMajorState,
TransactionState,
@@ -156,10 +157,10 @@ function updateGroupStatus(rg: RefreshGroupRecord): void {
);
if (allDone) {
if (anyFrozen) {
- rg.timestampFinished = AbsoluteTime.toTimestamp(AbsoluteTime.now());
+ rg.timestampFinished = TalerPreciseTimestamp.now();
rg.operationStatus = RefreshOperationStatus.FinishedWithError;
} else {
- rg.timestampFinished = AbsoluteTime.toTimestamp(AbsoluteTime.now());
+ rg.timestampFinished = TalerPreciseTimestamp.now();
rg.operationStatus = RefreshOperationStatus.Finished;
}
}
@@ -1046,12 +1047,12 @@ export async function createRefreshGroup(
estimatedOutputPerCoin: estimatedOutputPerCoin.map((x) =>
Amounts.stringify(x),
),
- timestampCreated: TalerProtocolTimestamp.now(),
+ timestampCreated: TalerPreciseTimestamp.now(),
};
if (oldCoinPubs.length == 0) {
logger.warn("created refresh group with zero coins");
- refreshGroup.timestampFinished = TalerProtocolTimestamp.now();
+ refreshGroup.timestampFinished = TalerPreciseTimestamp.now();
refreshGroup.operationStatus = RefreshOperationStatus.Finished;
}
@@ -1075,8 +1076,8 @@ export async function createRefreshGroup(
* Timestamp after which the wallet would do the next check for an auto-refresh.
*/
function getAutoRefreshCheckThreshold(d: DenominationRecord): AbsoluteTime {
- const expireWithdraw = AbsoluteTime.fromTimestamp(d.stampExpireWithdraw);
- const expireDeposit = AbsoluteTime.fromTimestamp(d.stampExpireDeposit);
+ const expireWithdraw = AbsoluteTime.fromProtocolTimestamp(d.stampExpireWithdraw);
+ const expireDeposit = AbsoluteTime.fromProtocolTimestamp(d.stampExpireDeposit);
const delta = AbsoluteTime.difference(expireWithdraw, expireDeposit);
const deltaDiv = durationMul(delta, 0.75);
return AbsoluteTime.addDuration(expireWithdraw, deltaDiv);
@@ -1086,8 +1087,8 @@ function getAutoRefreshCheckThreshold(d: DenominationRecord): AbsoluteTime {
* Timestamp after which the wallet would do an auto-refresh.
*/
function getAutoRefreshExecuteThreshold(d: DenominationRecord): AbsoluteTime {
- const expireWithdraw = AbsoluteTime.fromTimestamp(d.stampExpireWithdraw);
- const expireDeposit = AbsoluteTime.fromTimestamp(d.stampExpireDeposit);
+ const expireWithdraw = AbsoluteTime.fromProtocolTimestamp(d.stampExpireWithdraw);
+ const expireDeposit = AbsoluteTime.fromProtocolTimestamp(d.stampExpireDeposit);
const delta = AbsoluteTime.difference(expireWithdraw, expireDeposit);
const deltaDiv = durationMul(delta, 0.5);
return AbsoluteTime.addDuration(expireWithdraw, deltaDiv);
@@ -1174,7 +1175,7 @@ export async function autoRefresh(
logger.info(
`next refresh check at ${AbsoluteTime.toIsoString(minCheckThreshold)}`,
);
- exchange.nextRefreshCheck = AbsoluteTime.toTimestamp(minCheckThreshold);
+ exchange.nextRefreshCheck = AbsoluteTime.toPreciseTimestamp(minCheckThreshold);
await tx.exchanges.put(exchange);
});
return OperationAttemptResult.finishedEmpty();