Clarify cfgsync builder base config struct

This commit is contained in:
andrussal 2025-12-10 09:45:19 +01:00
parent 881ead1e32
commit a48bf0415e

View File

@ -8,10 +8,15 @@ use rand::{Rng as _, thread_rng};
use testing_framework_config::topology::configs::{ use testing_framework_config::topology::configs::{
GeneralConfig, GeneralConfig,
api::GeneralApiConfig, api::GeneralApiConfig,
blend,
blend::create_blend_configs, blend::create_blend_configs,
bootstrap,
bootstrap::{SHORT_PROLONGED_BOOTSTRAP_PERIOD, create_bootstrap_configs}, bootstrap::{SHORT_PROLONGED_BOOTSTRAP_PERIOD, create_bootstrap_configs},
consensus,
consensus::{ConsensusParams, create_consensus_configs, create_genesis_tx_with_declarations}, consensus::{ConsensusParams, create_consensus_configs, create_genesis_tx_with_declarations},
da,
da::{DaParams, create_da_configs}, da::{DaParams, create_da_configs},
network,
network::{NetworkParams, create_network_configs}, network::{NetworkParams, create_network_configs},
time::default_time_config, time::default_time_config,
wallet::WalletConfig, wallet::WalletConfig,
@ -52,15 +57,20 @@ pub fn create_node_configs(
let ports = resolve_da_ports(consensus_params.n_participants, da_ports); let ports = resolve_da_ports(consensus_params.n_participants, da_ports);
let blend_ports = resolve_blend_ports(&hosts, blend_ports); let blend_ports = resolve_blend_ports(&hosts, blend_ports);
let (mut consensus_configs, bootstrap_configs, da_configs, network_configs, blend_configs) = let BaseConfigs {
build_base_configs( mut consensus_configs,
consensus_params, bootstrap_configs,
da_params, da_configs,
wallet_config, network_configs,
&ids, blend_configs,
&ports, } = build_base_configs(
&blend_ports, consensus_params,
); da_params,
wallet_config,
&ids,
&ports,
&blend_ports,
);
let api_configs = build_api_configs(&hosts); let api_configs = build_api_configs(&hosts);
let mut configured_hosts = HashMap::new(); let mut configured_hosts = HashMap::new();
@ -182,26 +192,14 @@ fn build_base_configs(
ids: &[[u8; 32]], ids: &[[u8; 32]],
da_ports: &[u16], da_ports: &[u16],
blend_ports: &[u16], blend_ports: &[u16],
) -> ( ) -> BaseConfigs {
Vec<testing_framework_config::topology::configs::consensus::GeneralConsensusConfig>, BaseConfigs {
Vec<testing_framework_config::topology::configs::bootstrap::GeneralBootstrapConfig>, consensus_configs: create_consensus_configs(ids, consensus_params, wallet_config),
Vec<testing_framework_config::topology::configs::da::GeneralDaConfig>, bootstrap_configs: create_bootstrap_configs(ids, SHORT_PROLONGED_BOOTSTRAP_PERIOD),
Vec<testing_framework_config::topology::configs::network::GeneralNetworkConfig>, da_configs: create_da_configs(ids, da_params, da_ports),
Vec<testing_framework_config::topology::configs::blend::GeneralBlendConfig>, network_configs: create_network_configs(ids, &NetworkParams::default()),
) { blend_configs: create_blend_configs(ids, blend_ports),
let consensus_configs = create_consensus_configs(ids, consensus_params, wallet_config); }
let bootstrap_configs = create_bootstrap_configs(ids, SHORT_PROLONGED_BOOTSTRAP_PERIOD);
let da_configs = create_da_configs(ids, da_params, da_ports);
let network_configs = create_network_configs(ids, &NetworkParams::default());
let blend_configs = create_blend_configs(ids, blend_ports);
(
consensus_configs,
bootstrap_configs,
da_configs,
network_configs,
blend_configs,
)
} }
fn build_api_configs(hosts: &[Host]) -> Vec<GeneralApiConfig> { fn build_api_configs(hosts: &[Host]) -> Vec<GeneralApiConfig> {
@ -226,3 +224,11 @@ fn build_peer_ids(ids: &[[u8; 32]]) -> Vec<PeerId> {
}) })
.collect() .collect()
} }
struct BaseConfigs {
consensus_configs: Vec<consensus::GeneralConsensusConfig>,
bootstrap_configs: Vec<bootstrap::GeneralBootstrapConfig>,
da_configs: Vec<da::GeneralDaConfig>,
network_configs: Vec<network::GeneralNetworkConfig>,
blend_configs: Vec<blend::GeneralBlendConfig>,
}