diff options
author | Florian Dold <florian@dold.me> | 2021-06-25 13:27:06 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-06-25 13:27:06 +0200 |
commit | 42fe57632002e8f6dbf175b4e984b2fa1013bbe9 (patch) | |
tree | bb672ac371e5c448b12bbf287f62dfff00495596 /packages/taler-wallet-core/src/db.ts | |
parent | 3603a6866977600e9cb16f5e94488fde9cfb02a5 (diff) | |
download | wallet-core-42fe57632002e8f6dbf175b4e984b2fa1013bbe9.tar.xz |
implement backup scheduling, other tweaks
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 48 |
1 files changed, 29 insertions, 19 deletions
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<BackupProviderRecord>("backupProviders", { keyPath: "baseUrl", }), - {}, + { + byPaymentProposalId: describeIndex( + "byPaymentProposalId", + "paymentProposalIds", + { + multiEntry: true, + }, + ), + }, ), depositGroups: describeStore( describeContents<DepositGroupRecord>("depositGroups", { |