Skip to content

Commit

Permalink
chore: dont gossip to disconnected nodes if there are no connected no…
Browse files Browse the repository at this point in the history
…des available
  • Loading branch information
njgheorghita committed Nov 27, 2023
1 parent e09953b commit 1047c77
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
24 changes: 0 additions & 24 deletions portalnet/src/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,6 @@ pub fn propagate_gossip_cross_thread<TContentKey: OverlayContentKey>(
})
.collect();

if all_nodes.is_empty() {
warn!("No connected nodes, using disconnected nodes for gossip.");
all_nodes = kbuckets
.buckets_iter()
.flat_map(|kbucket| {
kbucket
.iter()
.collect::<Vec<&kbucket::Node<NodeId, Node>>>()
})
.collect();
}

if all_nodes.is_empty() {
// If there are no nodes whatsoever in the routing table the gossip cannot proceed.
warn!("No nodes in routing table, gossip cannot proceed.");
Expand Down Expand Up @@ -142,18 +130,6 @@ pub async fn trace_propagate_gossip_cross_thread<TContentKey: OverlayContentKey>
})
.collect();

if all_nodes.is_empty() {
warn!("No connected nodes, using disconnected nodes for gossip.");
all_nodes = kbuckets
.buckets_iter()
.flat_map(|kbucket| {
kbucket
.iter()
.collect::<Vec<&kbucket::Node<NodeId, Node>>>()
})
.collect();
}

if all_nodes.is_empty() {
// If there are no nodes whatsoever in the routing table the gossip cannot proceed.
warn!("No nodes in routing table, gossip cannot proceed.");
Expand Down
12 changes: 0 additions & 12 deletions portalnet/src/overlay_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2528,18 +2528,6 @@ where
};

let mut closest_enrs = self.closest_connected_nodes(&target_key, query_config.num_results);
if closest_enrs.is_empty() {
// If there are no connected nodes, use the closest nodes regardless of connectivity.
warn!("No connected nodes, using disconnected nodes for query.");
closest_enrs = self
.kbuckets
.write()
.closest_values(&target_key)
.map(|closest| closest.value.enr)
.take(query_config.num_results)
.collect();
}

if closest_enrs.is_empty() {
// If there are no nodes whatsoever in the routing table the query cannot proceed.
warn!("No nodes in routing table, query cannot proceed.");
Expand Down

0 comments on commit 1047c77

Please sign in to comment.