From 56671301096123d09c0a1cd6bae58c3cd440aaba Mon Sep 17 00:00:00 2001 From: Anton Yemelyanov Date: Sun, 28 Jul 2024 23:37:02 +0300 Subject: [PATCH] local configuration updates --- examples/{cluster.toml => local.toml} | 5 ++++- src/config.rs | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) rename examples/{cluster.toml => local.toml} (71%) diff --git a/examples/cluster.toml b/examples/local.toml similarity index 71% rename from examples/cluster.toml rename to examples/local.toml index 47f6ce7..707f6cf 100644 --- a/examples/cluster.toml +++ b/examples/local.toml @@ -4,7 +4,10 @@ # and edited to match the actual configuration of the cluster. # # For testing, run the resolver with the following command: -# cargo run --release -- --trace --verbose --config-file=examples/cluster.toml --auto-update +# cargo run --release -- --trace --verbose --config-file=examples/local.toml --auto-update +# +# To run under kHOST deployment, copy this file to `~/.kaspa-resolver/local.toml`. +# Existence of `~/.kaspa-resolver/local.toml` will override any other configuration settings. # [[node]] diff --git a/src/config.rs b/src/config.rs index f37cfed..bd46db4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -104,7 +104,19 @@ pub fn init(user_config: &Option) -> Result<()> { fs::create_dir_all(&global_config_folder)?; } - if let Some(user_config) = user_config { + let local_config_override = global_config_folder.join("local.toml"); + if local_config_override.exists() { + log_warn!( + "Config", + "Using local config override: `{}`", + local_config_override.display() + ); + let toml = fs::read_to_string(local_config_override)?; + USER_CONFIG + .lock() + .unwrap() + .replace(Config::try_parse(toml.as_str())?); + } else if let Some(user_config) = user_config { // let config_path = Path::new(config); if !user_config.exists() { Err(Error::custom(format!(