sui_swarm_config/
network_config.rs1use serde::{Deserialize, Serialize};
5use serde_with::serde_as;
6use sui_config::{Config, NodeConfig, genesis};
7use sui_types::committee::CommitteeWithNetworkMetadata;
8use sui_types::crypto::AccountKeyPair;
9use sui_types::multiaddr::Multiaddr;
10
11#[serde_as]
14#[derive(Debug, Deserialize, Serialize)]
15pub struct NetworkConfig {
16 pub validator_configs: Vec<NodeConfig>,
17 pub account_keys: Vec<AccountKeyPair>,
18 pub genesis: genesis::Genesis,
19}
20
21impl Config for NetworkConfig {}
22
23impl NetworkConfig {
24 pub fn validator_configs(&self) -> &[NodeConfig] {
25 &self.validator_configs
26 }
27
28 pub fn net_addresses(&self) -> Vec<Multiaddr> {
29 self.genesis
30 .committee_with_network()
31 .validators()
32 .values()
33 .map(|(_, n)| n.network_address.clone())
34 .collect()
35 }
36
37 pub fn committee_with_network(&self) -> CommitteeWithNetworkMetadata {
38 self.genesis.committee_with_network()
39 }
40
41 pub fn into_validator_configs(self) -> Vec<NodeConfig> {
42 self.validator_configs
43 }
44}