Skip to content

Commit

Permalink
Revert "[cherry-pick][cli] Cherry pick cli fix (#18469) (#18476)"
Browse files Browse the repository at this point in the history
This reverts commit 63cd80f.
  • Loading branch information
stefan-mysten committed Jul 12, 2024
1 parent 9c588e1 commit 8543da8
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions crates/sui/src/sui_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,31 +602,21 @@ async fn start(
let epoch_duration_ms = epoch_duration_ms.unwrap_or(DEFAULT_EPOCH_DURATION_MS);
swarm_builder = swarm_builder.with_epoch_duration_ms(epoch_duration_ms);
} else {
if config.is_none() && !sui_config_dir()?.join(SUI_NETWORK_CONFIG).exists() {
// load from config dir that was passed, or generate a new genesis if there is no config
// dir passed and there is no config_dir in the default location
// and if a dir exists, then use that one
if let Some(config) = config.clone() {
swarm_builder = swarm_builder.dir(config);
} else if config.is_none() && !sui_config_dir()?.join(SUI_NETWORK_CONFIG).exists() {
genesis(None, None, None, false, epoch_duration_ms, None, false).await?;
swarm_builder = swarm_builder.dir(sui_config_dir()?);
} else {
swarm_builder = swarm_builder.dir(sui_config_dir()?);
}

// Load the config of the Sui authority.
// To keep compatibility with sui-test-validator where the user can pass a config
// directory, this checks if the config is a file or a directory
let network_config_path = if let Some(ref config) = config {
if config.is_dir() {
config.join(SUI_NETWORK_CONFIG)
} else if config.is_file()
&& config
.extension()
.is_some_and(|ext| (ext == "yml" || ext == "yaml"))
{
config.clone()
} else {
config.join(SUI_NETWORK_CONFIG)
}
} else {
config
.clone()
.unwrap_or(sui_config_dir()?)
.join(SUI_NETWORK_CONFIG)
};
let network_config_path = config
.clone()
.unwrap_or(sui_config_dir()?.join(SUI_NETWORK_CONFIG));
let network_config: NetworkConfig =
PersistedConfig::read(&network_config_path).map_err(|err| {
err.context(format!(
Expand All @@ -635,9 +625,7 @@ async fn start(
))
})?;

swarm_builder = swarm_builder
.dir(sui_config_dir()?)
.with_network_config(network_config);
swarm_builder = swarm_builder.with_network_config(network_config);
}

#[cfg(feature = "indexer")]
Expand Down

0 comments on commit 8543da8

Please sign in to comment.