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: get MAX_NODES_PER_BUCKET when respond closest #6842

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Feb 28, 2024

self.kbuckets.closest_values(&key) iterates over all buckets.

the neighbours response should include 16 nodes at most

@mattsse mattsse added C-bug An unexpected or incorrect behavior A-discv4 Related to discv4 discovery labels Feb 28, 2024
for nodes in all_nodes.chunks(SAFE_MAX_DATAGRAM_NEIGHBOUR_RECORDS) {
// get the MAX_NODES_PER_BUCKET closest nodes to the target
let closest_nodes =
self.kbuckets.closest_values(&key).take(MAX_NODES_PER_BUCKET).collect::<Vec<_>>();
Copy link
Member

@emhane emhane Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.kbuckets.closest_values(&key).take(MAX_NODES_PER_BUCKET).collect::<Vec<_>>();
self.kbuckets.closest_values(&key).collect::<Vec<_>>();

method closest_values on kbuckets already limits length of the vec

@emhane emhane added this pull request to the merge queue Feb 28, 2024
Merged via the queue into main with commit 0f26cd6 Feb 28, 2024
29 checks passed
@emhane emhane deleted the matt/only-take-max-nodes-per-bucket branch February 28, 2024 14:27
fgimenez pushed a commit to fgimenez/reth that referenced this pull request Feb 29, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-discv4 Related to discv4 discovery C-bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants