1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use crate::database::database_description::DatabaseDescription;
use fuel_core_storage::kv_store::StorageColumn;
use fuel_core_types::blockchain::primitives::DaBlockHeight;

/// The column used by the relayer database in the case if the relayer is disabled.
#[derive(
    Debug,
    Copy,
    Clone,
    strum_macros::EnumCount,
    strum_macros::IntoStaticStr,
    PartialEq,
    Eq,
    enum_iterator::Sequence,
    Hash,
)]
pub enum DummyColumn {
    Metadata,
}

impl StorageColumn for DummyColumn {
    fn name(&self) -> &'static str {
        self.into()
    }

    fn id(&self) -> u32 {
        *self as u32
    }
}

#[derive(Clone, Debug)]
pub struct Relayer;

impl DatabaseDescription for Relayer {
    #[cfg(feature = "relayer")]
    type Column = fuel_core_relayer::storage::Column;

    #[cfg(not(feature = "relayer"))]
    type Column = DummyColumn;

    type Height = DaBlockHeight;

    fn version() -> u32 {
        0
    }

    fn name() -> &'static str {
        "relayer"
    }

    fn metadata_column() -> Self::Column {
        Self::Column::Metadata
    }

    fn prefix(_: &Self::Column) -> Option<usize> {
        None
    }
}