Skip to content

Commit

Permalink
perf: crawl more aggressively
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Mar 4, 2022
1 parent 13608ea commit 1a80614
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .crawler/src/crawler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ impl Crawler {

// Connect to peers we haven't crawled in a while.
for addr in node.known_network.addrs_to_connect() {
let _ = node.node().connect(addr).await;
let node_clone = node.clone();
task::spawn(async move {
if node_clone.node().connect(addr).await.is_ok() {
let _ = node_clone.send_direct_message(addr, ClientMessage::PeerRequest);
}
});
}

debug!(parent: node.node().span(), "crawling the netowrk for more peers; asking peers for their peers");
Expand Down Expand Up @@ -251,7 +256,12 @@ impl Crawler {

// Only connect if this address is unknown.
if !node.known_network.nodes().contains_key(&peer_ip) {
let _ = node.node().connect(peer_ip).await;
let node_clone = node.clone();
task::spawn(async move {
if node_clone.node().connect(peer_ip).await.is_ok() {
let _ = node_clone.send_direct_message(peer_ip, ClientMessage::PeerRequest);
}
});
}
}
}
Expand Down

0 comments on commit 1a80614

Please sign in to comment.