Skip to content

Commit

Permalink
fix: invalid forced sync peer now returns configerror (#3350)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
StriderDM authored Sep 15, 2021
1 parent 0757e9b commit 8163ef8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion applications/tari_base_node/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Result<Vec<_>, _>>()?;
.collect::<Result<Vec<_>, _>>()
.map_err(|e| anyhow!("Invalid force sync peer: {:?}", e))?;

debug!(target: LOG_TARGET, "{} sync peer(s) configured", sync_peers.len());

Expand Down
7 changes: 6 additions & 1 deletion applications/tari_base_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ async fn run_node(node_config: Arc<GlobalConfig>, 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::<HiddenServiceControllerError>()
Expand All @@ -221,6 +220,12 @@ async fn run_node(node_config: Arc<GlobalConfig>, 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
})?;
Expand Down

0 comments on commit 8163ef8

Please sign in to comment.