Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
protocols/kad: Add Kademlia::get_closest_local_peers #2436
protocols/kad: Add Kademlia::get_closest_local_peers #2436
Changes from 8 commits
e0bf30c
dbe55b2
5ea5247
7f483c7
703d710
bd6b4c3
2785d16
4d26886
ca50148
6479ac4
d085312
a992756
300df3d
2c2596e
12f645c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not mirror the signature of
get_closest_peers
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we have to pass
key
as a reference, so function can return animpl Iterator
that would use that reference.We can't pass key by value, because then
fn get_local_closest_peers
will own it and drop, thus invalidatingimpl Iterator
. Borrow checker would be unhappy about that :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible to do it this way:
Do you find that better than the current version?
P.S.
Into<Vec<u8>>
isn't required forget_local_closest_peers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a second thought,
K: AsRef<kbucket::Key<K>> + Clone
doesn't make sense. It does make sense to doK: Into<Key<K>>
, cuz then if refers to the followingFrom
impls:But since there aren't any analogous
AsRef<Key<_>>
impls, the boundK: AsRef<kbucket::Key<K>>
doesn't make sense.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I see best to stay with
key: &'k kbucket::Key<K>
and renameK
toT
for naming consistency. WDYT?Did that. Now it looks like this: