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/// The state of the server returned via APIs
33#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
34pub enum ServerStatus {
35 AwaitingLocalParams,
36 /// Waiting for peers to share the config gen params
37 CollectingConnectionInfo(Vec<String>),
38 /// Consensus is running
39 ConsensusRunning,
40}
41
42/// Sent by admin user to the API
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct ConfigGenConnectionsRequest {
45 /// Our guardian name
46 pub our_name: String,
47 /// URL of "leader" guardian to send our connection info to
48 /// Will be `None` if we are the leader
49 pub leader_api_url: Option<SafeUrl>,
50}
51
52#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
53/// Connection information sent between peers in order to start config gen
54pub struct PeerServerParams {
55 /// TLS cert is necessary for P2P auth during DKG and consensus
56 pub cert: String,
57 /// P2P is the network for running DKG and consensus
58 pub p2p_url: SafeUrl,
59 /// API for secure websocket requests
60 pub api_url: SafeUrl,
61 /// Name of the peer, used in TLS auth
62 pub name: String,
63 /// Status of the peer if known
64 pub status: Option<ServerStatusLegacy>,
65}
66
67#[derive(Clone, Debug, Serialize, Deserialize)]
68pub struct SetLocalParamsRequest {
69 /// Name of the peer, used in TLS auth
70 pub name: String,
71 /// Federation name set by the leader
72 pub federation_name: Option<String>,
73}