fedimint_dummy_client/
db.rs

1use fedimint_core::encoding::{Decodable, Encodable};
2use fedimint_core::module::AmountUnit;
3use fedimint_core::{Amount, impl_db_lookup, impl_db_record};
4use strum_macros::EnumIter;
5
6#[repr(u8)]
7#[derive(Clone, Debug, EnumIter)]
8pub enum DbKeyPrefix {
9    ClientFunds = 0x04,
10    /// Prefixes between 0xb0..=0xcf shall all be considered allocated for
11    /// historical and future external use
12    ExternalReservedStart = 0xb0,
13    /// Prefixes between 0xd0..=0xff shall all be considered allocated for
14    /// historical and future internal use
15    CoreInternalReservedStart = 0xd0,
16    /// Prefixes between 0xd0..=0xff shall all be considered allocated for
17    /// historical and future internal use
18    CoreInternalReservedEnd = 0xff,
19}
20
21impl std::fmt::Display for DbKeyPrefix {
22    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
23        write!(f, "{self:?}")
24    }
25}
26
27#[derive(Debug, Clone, Encodable, Decodable, Eq, PartialEq, Hash)]
28pub struct DummyClientFundsKey(pub AmountUnit);
29
30impl_db_record!(
31    key = DummyClientFundsKey,
32    value = Amount,
33    db_prefix = DbKeyPrefix::ClientFunds,
34);
35
36#[derive(Debug, Clone, Encodable, Decodable, Eq, PartialEq, Hash)]
37pub struct DummyClientFundsKeyPrefixAll;
38
39impl_db_lookup!(
40    key = DummyClientFundsKey,
41    query_prefix = DummyClientFundsKeyPrefixAll,
42);