Skip to content

Commit

Permalink
local configuration updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Jul 28, 2024
1 parent d2f19ba commit 5667130
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion examples/cluster.toml → examples/local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
14 changes: 13 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,19 @@ pub fn init(user_config: &Option<PathBuf>) -> 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!(
Expand Down

0 comments on commit 5667130

Please sign in to comment.