From 42fe57632002e8f6dbf175b4e984b2fa1013bbe9 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Fri, 25 Jun 2021 13:27:06 +0200 Subject: implement backup scheduling, other tweaks --- packages/taler-wallet-core/src/db.ts | 48 ++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'packages/taler-wallet-core/src/db.ts') diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index e640e7f20..2a2aba461 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1552,11 +1552,26 @@ export interface RecoupGroupRecord { lastError: TalerErrorDetails | undefined; } -export enum BackupProviderStatus { - PaymentRequired = "payment-required", +export enum BackupProviderStateTag { + Provisional = "provisional", Ready = "ready", + Retrying = "retrying", } +export type BackupProviderState = + | { + tag: BackupProviderStateTag.Provisional; + } + | { + tag: BackupProviderStateTag.Ready; + nextBackupTimestamp: Timestamp; + } + | { + tag: BackupProviderStateTag.Retrying; + retryInfo: RetryInfo; + lastError?: TalerErrorDetails; + }; + export interface BackupProviderTerms { supportedProtocolVersion: string; annualFee: AmountString; @@ -1578,8 +1593,6 @@ export interface BackupProviderRecord { */ terms?: BackupProviderTerms; - active: boolean; - /** * Hash of the last encrypted backup that we already merged * or successfully uploaded ourselves. @@ -1599,6 +1612,8 @@ export interface BackupProviderRecord { * Proposal that we're currently trying to pay for. * * (Also included in paymentProposalIds.) + * + * FIXME: Make this part of a proper BackupProviderState? */ currentPaymentProposalId?: string; @@ -1610,20 +1625,7 @@ export interface BackupProviderRecord { */ paymentProposalIds: string[]; - /** - * Next scheduled backup. - */ - nextBackupTimestamp?: Timestamp; - - /** - * Retry info. - */ - retryInfo: RetryInfo; - - /** - * Last error that occurred, if any. - */ - lastError: TalerErrorDetails | undefined; + state: BackupProviderState; /** * UIDs for the operation that added the backup provider. @@ -1851,7 +1853,15 @@ export const WalletStoresV1 = { describeContents("backupProviders", { keyPath: "baseUrl", }), - {}, + { + byPaymentProposalId: describeIndex( + "byPaymentProposalId", + "paymentProposalIds", + { + multiEntry: true, + }, + ), + }, ), depositGroups: describeStore( describeContents("depositGroups", { -- cgit v1.2.3