From 8163ef8bf622fb1c8b1bbf98ff0f4b8daaa99083 Mon Sep 17 00:00:00 2001 From: David Main <51991544+StriderDM@users.noreply.github.com> Date: Wed, 15 Sep 2021 16:24:28 +0200 Subject: [PATCH] fix: invalid forced sync peer now returns configerror (#3350) Description --- Fixed bug which returned an UnknownError instead of a ConfigError for invalid force sync peers. Remove double print of error. Output: ``` Running `target\debug\tari_base_node.exe` Initializing logging according to "C:\\Users\\DMStrider\\.tari\\config\\log4rs_base_node.yml" Please check your force sync peers configuration ConfigError("Invalid force sync peer: Invalid public key string") 14:43 ERROR Exiting with code (101): ConfigError("Invalid force sync peer: Invalid public key string") ``` Motivation and Context --- Previously an UnknownError was reported for invalid force sync peers How Has This Been Tested? --- Configuration with invalid force_sync_peers. --- applications/tari_base_node/src/bootstrap.rs | 3 ++- applications/tari_base_node/src/main.rs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/applications/tari_base_node/src/bootstrap.rs b/applications/tari_base_node/src/bootstrap.rs index 0d5576d068..daee21c21b 100644 --- a/applications/tari_base_node/src/bootstrap.rs +++ b/applications/tari_base_node/src/bootstrap.rs @@ -104,7 +104,8 @@ where B: BlockchainBackend + 'static .iter() .map(|s| SeedPeer::from_str(s)) .map(|r| r.map(Peer::from).map(|p| p.node_id)) - .collect::, _>>()?; + .collect::, _>>() + .map_err(|e| anyhow!("Invalid force sync peer: {:?}", e))?; debug!(target: LOG_TARGET, "{} sync peer(s) configured", sync_peers.len()); diff --git a/applications/tari_base_node/src/main.rs b/applications/tari_base_node/src/main.rs index 7a35a38021..933311b0ab 100644 --- a/applications/tari_base_node/src/main.rs +++ b/applications/tari_base_node/src/main.rs @@ -204,7 +204,6 @@ async fn run_node(node_config: Arc, bootstrap: ConfigBootstrap) -> ) .await .map_err(|err| { - error!(target: LOG_TARGET, "{}", err); for boxed_error in err.chain() { if let Some(HiddenServiceControllerError::TorControlPortOffline) = boxed_error.downcast_ref::() @@ -221,6 +220,12 @@ async fn run_node(node_config: Arc, bootstrap: ConfigBootstrap) -> ); return ExitCodes::TorOffline; } + + // todo: find a better way to do this + if boxed_error.to_string().contains("Invalid force sync peer") { + println!("Please check your force sync peers configuration"); + return ExitCodes::ConfigError(boxed_error.to_string()); + } } ExitCodes::UnknownError })?;