Skip to content

Commit

Permalink
config: add helper for creating local socket address on an avaiable port
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed May 31, 2022
1 parent de9abe2 commit 66517c7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 1 addition & 3 deletions crates/sui-config/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
db_path,
network_address,
metrics_address,
json_rpc_address: format!("127.0.0.1:{}", utils::get_available_port())
.parse()
.unwrap(),
json_rpc_address: utils::available_local_socket_address(),
consensus_config: Some(consensus_config),
committee_config: committee_config.clone(),
genesis: genesis.clone(),
Expand Down
4 changes: 1 addition & 3 deletions crates/sui-config/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ impl NetworkConfig {
db_path: db_path.join(FULL_NODE_DB_PATH),
network_address: utils::new_network_address(),
metrics_address: utils::new_network_address(),
json_rpc_address: format!("127.0.0.1:{}", utils::get_available_port())
.parse()
.unwrap(),
json_rpc_address: utils::available_local_socket_address(),

consensus_config: None,
committee_config: validator_config.committee_config.clone(),
Expand Down
6 changes: 6 additions & 0 deletions crates/sui-config/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ pub fn new_network_address() -> multiaddr::Multiaddr {
.parse()
.unwrap()
}

pub fn available_local_socket_address() -> std::net::SocketAddr {
format!("127.0.0.1:{}", get_available_port())
.parse()
.unwrap()
}

0 comments on commit 66517c7

Please sign in to comment.