From 9a369a024558f217edcd0fd220e788522fea4760 Mon Sep 17 00:00:00 2001 From: Martin Stefcek <35243812+Cifko@users.noreply.github.com> Date: Tue, 5 Oct 2021 21:57:01 +0400 Subject: [PATCH] fix: network switching (#3413) Description --- When the base node is runned with command `-network ` everything is loaded from them correct folder. How Has This Been Tested? --- Manually. --- applications/tari_app_utilities/src/initialization.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/applications/tari_app_utilities/src/initialization.rs b/applications/tari_app_utilities/src/initialization.rs index 2497788307..85c711d4e3 100644 --- a/applications/tari_app_utilities/src/initialization.rs +++ b/applications/tari_app_utilities/src/initialization.rs @@ -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) => { @@ -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!( @@ -53,6 +60,7 @@ pub fn init_configuration( }, } } + check_file_paths(&mut global_config, &bootstrap); Ok((bootstrap, global_config, cfg)) }