Skip to content

Commit

Permalink
config: generate random json-rpc listen addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed May 27, 2022
1 parent 5c46649 commit 4681eeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions crates/sui-config/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use std::{
use sui_types::{base_types::encode_bytes_hex, crypto::get_key_pair_from_rng};

use crate::{
genesis, new_network_address, CommitteeConfig, ConsensusConfig, GenesisConfig, NetworkConfig,
NodeConfig, ValidatorGenesisInfo, ValidatorInfo, AUTHORITIES_DB_NAME, CONSENSUS_DB_NAME,
DEFAULT_STAKE,
genesis, new_network_address, utils, CommitteeConfig, ConsensusConfig, GenesisConfig,
NetworkConfig, NodeConfig, ValidatorGenesisInfo, ValidatorInfo, AUTHORITIES_DB_NAME,
CONSENSUS_DB_NAME, DEFAULT_STAKE,
};

pub struct ConfigBuilder<R = OsRng> {
Expand Down Expand Up @@ -196,7 +196,9 @@ impl<R: ::rand::RngCore + ::rand::CryptoRng> ConfigBuilder<R> {
db_path,
network_address,
metrics_address,
json_rpc_address: "127.0.0.1:5002".parse().unwrap(),
json_rpc_address: format!("127.0.0.1:{}", utils::get_available_port())
.parse()
.unwrap(),
consensus_config: Some(consensus_config),
committee_config: committee_config.clone(),
genesis: genesis.clone(),
Expand Down
4 changes: 3 additions & 1 deletion crates/sui-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ impl NetworkConfig {
db_path: db_path.join("fullnode"),
network_address: new_network_address(),
metrics_address: new_network_address(),
json_rpc_address: validator_config.json_rpc_address,
json_rpc_address: format!("127.0.0.1:{}", utils::get_available_port())
.parse()
.unwrap(),

consensus_config: None,
committee_config: validator_config.committee_config.clone(),
Expand Down

0 comments on commit 4681eeb

Please sign in to comment.