Define ClusterConfig::new_with_equal_stakes() (#32330)
* Define ClusterConfig::new_with_equal_stakes() * Remove needless variable assignment
This commit is contained in:
parent
b722ce4519
commit
f949a95a9e
|
@ -93,6 +93,24 @@ pub struct ClusterConfig {
|
||||||
pub tpu_connection_pool_size: usize,
|
pub tpu_connection_pool_size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ClusterConfig {
|
||||||
|
pub fn new_with_equal_stakes(
|
||||||
|
num_nodes: usize,
|
||||||
|
cluster_lamports: u64,
|
||||||
|
lamports_per_node: u64,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
node_stakes: vec![lamports_per_node; num_nodes],
|
||||||
|
cluster_lamports,
|
||||||
|
validator_configs: make_identical_validator_configs(
|
||||||
|
&ValidatorConfig::default_for_test(),
|
||||||
|
num_nodes,
|
||||||
|
),
|
||||||
|
..Self::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for ClusterConfig {
|
impl Default for ClusterConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
ClusterConfig {
|
ClusterConfig {
|
||||||
|
@ -133,17 +151,14 @@ impl LocalCluster {
|
||||||
lamports_per_node: u64,
|
lamports_per_node: u64,
|
||||||
socket_addr_space: SocketAddrSpace,
|
socket_addr_space: SocketAddrSpace,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let stakes: Vec<_> = (0..num_nodes).map(|_| lamports_per_node).collect();
|
Self::new(
|
||||||
let mut config = ClusterConfig {
|
&mut ClusterConfig::new_with_equal_stakes(
|
||||||
node_stakes: stakes,
|
|
||||||
cluster_lamports,
|
|
||||||
validator_configs: make_identical_validator_configs(
|
|
||||||
&ValidatorConfig::default_for_test(),
|
|
||||||
num_nodes,
|
num_nodes,
|
||||||
|
cluster_lamports,
|
||||||
|
lamports_per_node,
|
||||||
),
|
),
|
||||||
..ClusterConfig::default()
|
socket_addr_space,
|
||||||
};
|
)
|
||||||
Self::new(&mut config, socket_addr_space)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync_ledger_path_across_nested_config_fields(
|
fn sync_ledger_path_across_nested_config_fields(
|
||||||
|
|
Loading…
Reference in New Issue