fedimint_meta_common/
config.rs

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
59
60
61
62
63
64
65
66
67
use fedimint_core::core::ModuleKind;
use fedimint_core::encoding::{Decodable, Encodable};
use fedimint_core::plugin_types_trait_impl_config;
use serde::{Deserialize, Serialize};

use crate::MetaCommonInit;

/// Parameters necessary to generate this module's configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MetaGenParams {
    pub local: MetaGenParamsLocal,
    pub consensus: MetaGenParamsConsensus,
}

/// Local parameters for config generation
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct MetaGenParamsLocal;

/// Consensus parameters for config generation
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MetaGenParamsConsensus;

impl Default for MetaGenParams {
    fn default() -> Self {
        Self {
            local: MetaGenParamsLocal,
            consensus: MetaGenParamsConsensus,
        }
    }
}

/// Contains all the configuration for the server
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MetaConfig {
    pub local: MetaConfigLocal,
    pub private: MetaConfigPrivate,
    pub consensus: MetaConfigConsensus,
}

/// Contains all the configuration for the client
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Encodable, Decodable, Hash)]
pub struct MetaClientConfig;

/// Locally unencrypted config unique to each member
#[derive(Clone, Debug, Serialize, Deserialize, Decodable, Encodable)]
pub struct MetaConfigLocal;

/// Will be the same for every federation member
#[derive(Clone, Debug, Serialize, Deserialize, Decodable, Encodable)]
pub struct MetaConfigConsensus;

/// Will be encrypted and not shared such as private key material
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MetaConfigPrivate;

// Wire together the configs for this module
plugin_types_trait_impl_config!(
    MetaCommonInit,
    MetaGenParams,
    MetaGenParamsLocal,
    MetaGenParamsConsensus,
    MetaConfig,
    MetaConfigLocal,
    MetaConfigPrivate,
    MetaConfigConsensus,
    MetaClientConfig
);