Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit f949a95

Browse files
authored
Define ClusterConfig::new_with_equal_stakes() (#32330)
* Define ClusterConfig::new_with_equal_stakes() * Remove needless variable assignment
1 parent b722ce4 commit f949a95

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

local-cluster/src/local_cluster.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ pub struct ClusterConfig {
9393
pub tpu_connection_pool_size: usize,
9494
}
9595

96+
impl ClusterConfig {
97+
pub fn new_with_equal_stakes(
98+
num_nodes: usize,
99+
cluster_lamports: u64,
100+
lamports_per_node: u64,
101+
) -> Self {
102+
Self {
103+
node_stakes: vec![lamports_per_node; num_nodes],
104+
cluster_lamports,
105+
validator_configs: make_identical_validator_configs(
106+
&ValidatorConfig::default_for_test(),
107+
num_nodes,
108+
),
109+
..Self::default()
110+
}
111+
}
112+
}
113+
96114
impl Default for ClusterConfig {
97115
fn default() -> Self {
98116
ClusterConfig {
@@ -133,17 +151,14 @@ impl LocalCluster {
133151
lamports_per_node: u64,
134152
socket_addr_space: SocketAddrSpace,
135153
) -> Self {
136-
let stakes: Vec<_> = (0..num_nodes).map(|_| lamports_per_node).collect();
137-
let mut config = ClusterConfig {
138-
node_stakes: stakes,
139-
cluster_lamports,
140-
validator_configs: make_identical_validator_configs(
141-
&ValidatorConfig::default_for_test(),
154+
Self::new(
155+
&mut ClusterConfig::new_with_equal_stakes(
142156
num_nodes,
157+
cluster_lamports,
158+
lamports_per_node,
143159
),
144-
..ClusterConfig::default()
145-
};
146-
Self::new(&mut config, socket_addr_space)
160+
socket_addr_space,
161+
)
147162
}
148163

149164
fn sync_ledger_path_across_nested_config_fields(

0 commit comments

Comments
 (0)