fedimint_lnv2_client/
db.rs

1use fedimint_core::encoding::{Decodable, Encodable};
2use fedimint_core::secp256k1::PublicKey;
3use fedimint_core::util::SafeUrl;
4use fedimint_core::{impl_db_lookup, impl_db_record};
5use strum::EnumIter;
6
7#[repr(u8)]
8#[derive(Clone, EnumIter, Debug)]
9pub enum DbKeyPrefix {
10    Gateway = 0x41,
11    #[allow(dead_code)]
12    /// Prefixes between 0xb0..=0xcf shall all be considered allocated for
13    /// historical and future external use
14    ExternalReservedStart = 0xb0,
15    #[allow(dead_code)]
16    /// Prefixes between 0xd0..=0xff shall all be considered allocated for
17    /// historical and future internal use
18    CoreInternalReservedStart = 0xd0,
19    #[allow(dead_code)]
20    CoreInternalReservedEnd = 0xff,
21}
22
23#[derive(Debug, Encodable, Decodable)]
24pub struct GatewayKey(pub PublicKey);
25
26#[derive(Debug, Encodable, Decodable)]
27pub struct GatewayPrefix;
28
29impl_db_record!(
30    key = GatewayKey,
31    value = SafeUrl,
32    db_prefix = DbKeyPrefix::Gateway,
33);
34impl_db_lookup!(key = GatewayKey, query_prefix = GatewayPrefix);