diff options
author | Florian Dold <florian@dold.me> | 2023-05-26 12:19:32 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-05-26 12:19:32 +0200 |
commit | cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854 (patch) | |
tree | 423ed7c6fc42ec5e05f655eb093b3b4bdc885996 /packages/taler-wallet-core/src/operations/backup/index.ts | |
parent | 557dcec30db6573c5d11ca26432008ac6621642e (diff) | |
download | wallet-core-cd8f76db61f4a1ab1a8a8a4d29b2f3e863b59854.tar.xz |
taler-util,wallet-core: implement TalerPreciseTimestamp
Fixes #7703
Diffstat (limited to 'packages/taler-wallet-core/src/operations/backup/index.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/backup/index.ts | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/packages/taler-wallet-core/src/operations/backup/index.ts b/packages/taler-wallet-core/src/operations/backup/index.ts index 59e99b505..f726167da 100644 --- a/packages/taler-wallet-core/src/operations/backup/index.ts +++ b/packages/taler-wallet-core/src/operations/backup/index.ts @@ -71,6 +71,7 @@ import { TalerErrorCode, TalerErrorDetail, TalerProtocolTimestamp, + TalerPreciseTimestamp, URL, WalletBackupContentV1, } from "@gnu-taler/taler-util"; @@ -246,9 +247,9 @@ interface BackupForProviderArgs { backupProviderBaseUrl: string; } -function getNextBackupTimestamp(): TalerProtocolTimestamp { +function getNextBackupTimestamp(): TalerPreciseTimestamp { // FIXME: Randomize! - return AbsoluteTime.toTimestamp( + return AbsoluteTime.toPreciseTimestamp( AbsoluteTime.addDuration( AbsoluteTime.now(), durationFromSpec({ minutes: 5 }), @@ -329,7 +330,7 @@ async function runBackupCycleForProvider( if (!prov) { return; } - prov.lastBackupCycleTimestamp = TalerProtocolTimestamp.now(); + prov.lastBackupCycleTimestamp = TalerPreciseTimestamp.now(); prov.state = { tag: BackupProviderStateTag.Ready, nextBackupTimestamp: getNextBackupTimestamp(), @@ -442,7 +443,7 @@ async function runBackupCycleForProvider( return; } prov.lastBackupHash = encodeCrock(currentBackupHash); - prov.lastBackupCycleTimestamp = TalerProtocolTimestamp.now(); + prov.lastBackupCycleTimestamp = TalerPreciseTimestamp.now(); prov.state = { tag: BackupProviderStateTag.Ready, nextBackupTimestamp: getNextBackupTimestamp(), @@ -676,7 +677,7 @@ export async function addBackupProvider( if (req.activate) { oldProv.state = { tag: BackupProviderStateTag.Ready, - nextBackupTimestamp: TalerProtocolTimestamp.now(), + nextBackupTimestamp: TalerPreciseTimestamp.now(), }; logger.info("setting existing backup provider to active"); await tx.backupProviders.put(oldProv); @@ -698,7 +699,7 @@ export async function addBackupProvider( if (req.activate) { state = { tag: BackupProviderStateTag.Ready, - nextBackupTimestamp: TalerProtocolTimestamp.now(), + nextBackupTimestamp: TalerPreciseTimestamp.now(), }; } else { state = { @@ -773,8 +774,8 @@ export interface ProviderInfo { * Last communication issue with the provider. */ lastError?: TalerErrorDetail; - lastSuccessfulBackupTimestamp?: TalerProtocolTimestamp; - lastAttemptedBackupTimestamp?: TalerProtocolTimestamp; + lastSuccessfulBackupTimestamp?: TalerPreciseTimestamp; + lastAttemptedBackupTimestamp?: TalerPreciseTimestamp; paymentProposalIds: string[]; backupProblem?: BackupProblem; paymentStatus: ProviderPaymentStatus; @@ -894,7 +895,7 @@ async function getProviderPaymentInfo( return { type: ProviderPaymentType.Paid, paidUntil: AbsoluteTime.addDuration( - AbsoluteTime.fromTimestamp(status.contractTerms.timestamp), + AbsoluteTime.fromProtocolTimestamp(status.contractTerms.timestamp), durationFromSpec({ years: 1 }), //FIXME: take this from the contract term ), }; @@ -1010,7 +1011,7 @@ async function backupRecoveryTheirs( shouldRetryFreshProposal: false, state: { tag: BackupProviderStateTag.Ready, - nextBackupTimestamp: TalerProtocolTimestamp.now(), + nextBackupTimestamp: TalerPreciseTimestamp.now(), }, uids: [encodeCrock(getRandomBytes(32))], }); |