Skip to content

Commit

Permalink
fix: network switching
Browse files Browse the repository at this point in the history
  • Loading branch information
Cifko committed Oct 5, 2021
1 parent 029dbfc commit ef08066
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion applications/tari_app_utilities/src/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ pub fn init_configuration(
// Populate the configuration struct
let mut global_config = GlobalConfig::convert_from(application_type, cfg.clone())
.map_err(|err| ExitCodes::ConfigError(err.to_string()))?;
check_file_paths(&mut global_config, &bootstrap);

if let Some(str) = bootstrap.network.clone() {
log::info!(target: LOG_TARGET, "Network selection requested");

let network = Network::from_str(&str);
match network {
Ok(network) => {
Expand All @@ -44,6 +44,13 @@ pub fn init_configuration(
network
);
global_config.network = network;
global_config.data_dir = PathBuf::from(str);
if let DatabaseType::LMDB(_) = global_config.db_type {
global_config.db_type = DatabaseType::LMDB(global_config.data_dir.join("db"));
}
global_config.peer_db_path = global_config.data_dir.join("peer_db");
global_config.wallet_peer_db_path = global_config.data_dir.join("wallet_peer_db");
global_config.console_wallet_peer_db_path = global_config.data_dir.join("console_wallet_peer_db");
},
Err(_) => {
log::warn!(
Expand All @@ -53,12 +60,14 @@ pub fn init_configuration(
},
}
}
check_file_paths(&mut global_config, &bootstrap);

Ok((bootstrap, global_config, cfg))
}

fn check_file_paths(config: &mut GlobalConfig, bootstrap: &ConfigBootstrap) {
let prepend = bootstrap.base_path.clone();
println!("{}:{} {:?}", file!(), line!(), config.data_dir);
if !config.data_dir.is_absolute() {
config.data_dir = concatenate_paths_normalized(prepend.clone(), config.data_dir.clone());
if let DatabaseType::LMDB(_) = config.db_type {
Expand Down

0 comments on commit ef08066

Please sign in to comment.