Skip to content

Commit

Permalink
fix: filter out disconnected nodes on Node/(Content Enr) response
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML committed Nov 27, 2023
1 parent dd1b670 commit 1e721ca
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion portalnet/src/overlay_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2360,11 +2360,15 @@ where
}
}

/// Returns a vector of all the ENRs of nodes currently contained in the routing table.
/// Returns a vector of all the ENRs of nodes currently contained in the routing table which are connected.
fn table_entries_enr(&self) -> Vec<Enr> {
self.kbuckets
.write()
.iter()
.filter(|entry| {
// Filter out disconnected nodes.
entry.status.is_connected()
})
.map(|entry| entry.node.value.enr())
.collect()
}
Expand All @@ -2387,6 +2391,10 @@ where
for node in kbuckets
.nodes_by_distances(log2_distances, FIND_NODES_MAX_NODES)
.into_iter()
.filter(|entry| {
// Filter out disconnected nodes.
entry.status.is_connected()
})
.map(|entry| entry.node.value.clone())
{
nodes_to_send.push(SszEnr::new(node.enr()));
Expand Down

0 comments on commit 1e721ca

Please sign in to comment.