Skip to content

Commit

Permalink
fix: proper error on empty bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef authored and Yoga07 committed Dec 3, 2020
1 parent da45ded commit db61592
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ impl QuicP2p {
let endpoint = self.new_endpoint()?;

trace!("Bootstrapping with nodes {:?}", endpoint.bootstrap_nodes());
if endpoint.bootstrap_nodes().is_empty() {
return Err(Error::Unexpected(
"No nodes for bootstrapping found".to_string(),
));
}

// Attempt to connect to all nodes and return the first one to succeed
let tasks = endpoint
Expand Down
6 changes: 6 additions & 0 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ impl Endpoint {
});
tasks.push(task_handle);
}
if tasks.is_empty() {
return Err(Error::Unexpected(
"No tasks for echo service connection".to_string(),
));
}

let (result, _) = futures::future::select_ok(tasks).await.map_err(|err| {
log::error!("Failed to contact echo service: {}", err);
Error::BootstrapFailure
Expand Down

0 comments on commit db61592

Please sign in to comment.