fedimint_core/admin_client.rs
1use std::fmt::Debug;
2
3use fedimint_core::util::SafeUrl;
4use serde::{Deserialize, Serialize};
5
6use crate::encoding::{Decodable, Encodable};
7
8/// The state of the server returned via APIs
9#[derive(Debug, Clone, Default, Serialize, Deserialize, Eq, PartialEq, Encodable, Decodable)]
10#[serde(rename_all = "snake_case")]
11pub enum ServerStatusLegacy {
12 /// Server needs a password to read configs
13 #[default]
14 AwaitingPassword,
15 /// Waiting for peers to share the config gen params
16 SharingConfigGenParams,
17 /// Ready to run config gen once all peers are ready
18 ReadyForConfigGen,
19 /// We failed running config gen
20 ConfigGenFailed,
21 /// Config is generated, peers should verify the config
22 VerifyingConfigs,
23 /// We have verified all our peer configs
24 VerifiedConfigs,
25 /// Consensus is running
26 ConsensusRunning,
27 /// Restarted setup. All peers need to sync on this state before continuing
28 /// to `SharingConfigGenParams`
29 SetupRestarted,
30}
31
32#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
33/// Connection information sent between peers in order to start config gen
34pub struct PeerServerParamsLegacy {
35 /// TLS cert is necessary for P2P auth during DKG and consensus
36 pub cert: String,
37 /// P2P is the network for running DKG and consensus
38 pub p2p_url: SafeUrl,
39 /// API for secure websocket requests
40 pub api_url: SafeUrl,
41 /// Name of the peer, used in TLS auth
42 pub name: String,
43 /// Status of the peer if known
44 pub status: Option<ServerStatusLegacy>,
45}
46
47/// The state of the server returned via APIs
48#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
49pub enum SetupStatus {
50 /// Waiting for guardian to set the local parameters
51 AwaitingLocalParams,
52 /// Sharing the connection codes with our peers
53 SharingConnectionCodes,
54 /// Consensus is running
55 ConsensusIsRunning,
56}
57
58#[derive(Clone, Debug, Serialize, Deserialize)]
59pub struct SetLocalParamsRequest {
60 /// Name of the peer, used in TLS auth
61 pub name: String,
62 /// Federation name set by the leader
63 pub federation_name: Option<String>,
64}