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: start with bucket idx 0 if local key #142

Merged
merged 1 commit into from
Oct 24, 2022

Conversation

mattsse
Copy link
Contributor

@mattsse mattsse commented Oct 24, 2022

If the local_key is provided for ClosestBucketsIter start it start in Start(BucketIndex(0)) instead of Done. otherwise, the closest_* iterators will always be empty and make it impossible lookup the local node in the DHT.

this is also the state libp2p-kad starts with if the local key was provided.

https://github.com/libp2p/rust-libp2p/blob/e530118fb017122786180570b2b68f89aac53905/protocols/kad/src/kbucket.rs#L361-L365

See also: https://docs.rs/libp2p-kad/0.41.0/src/libp2p_kad/behaviour.rs.html#831-856

Copy link
Member

@AgeManning AgeManning left a comment

Choose a reason for hiding this comment

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

Yeah nice, thanks.

I've been meaning to add the standard kad bootstrap query as a general function in the discv5 struct, just never got around to it, and hence why this bug has been left unnoticed.

Cheers :D

@AgeManning AgeManning merged commit 7d8c1ce into sigp:master Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants