1use std::time::SystemTime;
6
7use fedimint_core::encoding::{Decodable, Encodable};
8use fedimint_core::{impl_db_lookup, impl_db_record};
9use serde::{Deserialize, Serialize};
10
11use crate::db::DbKeyPrefix;
12
13#[derive(Debug, Clone, Copy, Encodable, Decodable, Serialize)]
15pub struct ClientBackupKey(pub secp256k1::PublicKey);
16
17#[derive(Debug, Encodable, Decodable)]
18pub struct ClientBackupKeyPrefix;
19
20impl_db_record!(
21 key = ClientBackupKey,
22 value = ClientBackupSnapshot,
23 db_prefix = DbKeyPrefix::ClientBackup,
24);
25impl_db_lookup!(key = ClientBackupKey, query_prefix = ClientBackupKeyPrefix);
26
27#[derive(Debug, Clone, PartialEq, Eq, Encodable, Decodable, Serialize, Deserialize)]
29pub struct ClientBackupSnapshot {
30 pub timestamp: SystemTime,
31 #[serde(with = "fedimint_core::hex::serde")]
32 pub data: Vec<u8>,
33}
34
35#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, Default)]
37pub struct BackupStatistics {
38 pub num_backups: usize,
39 pub total_size: usize,
40 pub refreshed_1d: usize,
41 pub refreshed_1w: usize,
42 pub refreshed_1m: usize,
43 pub refreshed_3m: usize,
44}