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

peer-routing getClosestPeers returns more than K nodes when using kad dht #1170

Closed
zeroxbt opened this issue Mar 17, 2022 · 3 comments
Closed

Comments

@zeroxbt
Copy link
Contributor

zeroxbt commented Mar 17, 2022

The getClosestPeers function in peer-routing.js returns more than K nodes when using the kad dht module.

The reason for this is that the getClosestPeers function in the kad-dht module yields not only FINAL_PEER events, but also DIALING_PEER, PEER_RESPONSE and SENDING_QUERYevents. In order to be compatible, either getClosestPeers from kad-dht module should return only FINAL_PEER events, or the getClosestPeers function in peer-routing.js should filter sources by FINAL_PEER events.

@zeroxbt zeroxbt added the need/triage Needs initial labeling and prioritization label Mar 17, 2022
@wemeetagain
Copy link
Member

@zeroxbt can you open a PR to fix this? 🙏 🙏

@zeroxbt
Copy link
Contributor Author

zeroxbt commented Sep 11, 2022

@wemeetagain I made a PR for this, and also found a bug that slows down kad dht find closest peers quite a bit. Please take a look when you have some time :)

libp2p/js-libp2p-kad-dht#371

@BigLep BigLep removed the need/triage Needs initial labeling and prioritization label Sep 13, 2022
@achingbrain
Copy link
Member

If you're only interested in the closest peers, you should disregard all events that are not FINAL_PEER. The others are useful for tracing and diagnostics, and for giving the user some feedback their query has not stalled but should not be treated as actual results.

@tinytb tinytb moved this to Done in js-libp2p Oct 11, 2022
@tinytb tinytb added this to js-libp2p Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

4 participants