Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the bootstrap process async again #356

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/bin/avail-light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,22 @@ async fn run(error_sender: Sender<anyhow::Error>) -> Result<()> {
.context("Listening on TCP not to fail.")?;
info!("Listening for TCP on port: {port}");

// wait here for bootstrap to finish
info!("Bootstraping the DHT with bootstrap nodes...");
p2p_client
.bootstrap_on_startup(cfg.clone().bootstraps.iter().map(Into::into).collect())
.await?;

info!("Bootstrap done");
let p2p_clone = p2p_client.to_owned();
let cfg_clone = cfg.to_owned();
tokio::spawn(async move {
info!("Bootstraping the DHT with bootstrap nodes...");
let bs_result = p2p_clone
.bootstrap_on_startup(cfg_clone.bootstraps.iter().map(Into::into).collect())
.await;
match bs_result {
Ok(_) => {
info!("Bootstrap done.");
},
Err(e) => {
error!("Error in the bootstrap process: {e:?}.");
},
}
});

#[cfg(feature = "network-analysis")]
tokio::task::spawn(analyzer::start_traffic_analyzer(cfg.port, 10));
Expand Down
Loading