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

fix: filter out disconnected nodes on Node/(Content Enr) response #1036

Merged
merged 1 commit into from
Nov 27, 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
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