Skip to content

Commit

Permalink
Added an extra warning message when failing to reach the node, work i…
Browse files Browse the repository at this point in the history
…n progress on changing default dir for node api ssecret 'foreign_api_secret'
  • Loading branch information
Anynomouss committed Jan 24, 2025
1 parent 3b0cc24 commit 82e61dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
25 changes: 23 additions & 2 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ fn check_config_current_dir(path: &str) -> Option<PathBuf> {
None
}

/// Checks if the node api secret in wallet dir, else return default path
fn check_node_api_exists(path: &str) -> Option<PathBuf> {
let p = env::current_dir();
let mut c = match p {
Ok(c) => c,
Err(_) => {
return None;
}
};
c.push(path);
if c.exists() {
return Some(c);
}
None
}

/// Whether a config file exists at the given directory
pub fn config_file_exists(path: &str) -> bool {
let mut path = PathBuf::from(path);
Expand Down Expand Up @@ -279,8 +295,13 @@ impl GlobalWalletConfig {
Some(secret_path.to_str().unwrap().to_owned());
let mut node_secret_path = wallet_home.clone();
node_secret_path.push(API_SECRET_FILE_NAME);
self.members.as_mut().unwrap().wallet.node_api_secret_path =
Some(node_secret_path.to_str().unwrap().to_owned());
// Set node API secret path to the wallet dir if it exists, else keep default home dir
// if node_secret_path.exists(){
// self.members.as_mut().unwrap().wallet.node_api_secret_path =
// Some(node_secret_path.to_str().unwrap().to_owned());
// println!("It node path does actually exists")
// }

let mut log_path = wallet_home.clone();
log_path.push(WALLET_LOG_FILE_NAME);
self.members
Expand Down
1 change: 1 addition & 0 deletions impls/src/node_clients/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl NodeClient for HTTPNodeClient {
});
} else {
error!("Unable to contact Node to get version info: {}", e);
warn!("Warning: You might need to correct 'node_api_secret_path' in your 'grin-wallet.toml' file");
return None;
}
}
Expand Down

0 comments on commit 82e61dd

Please sign in to comment.