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

UsefulPeer function #113

Merged
merged 3 commits into from
Jun 7, 2023
Merged

UsefulPeer function #113

merged 3 commits into from
Jun 7, 2023

Conversation

guillaumemichel
Copy link
Contributor

UsefulPeer verifies whether a given peer.ID would be a good fit for the routing table. It returns true if the bucket corresponding to peer.ID isn't full, if it contains replaceable peers or if it is the last bucket and adding a peer would unfold it.

This function is necessary for go-libp2p-kad-dht, as remote DHT servers are queried before they are added to the DHT. We don't want to query peers whose ID belong to a full bucket anyway. This function helps preventing querying useless peers.

References: libp2p/go-libp2p-kad-dht#820

table.go Outdated Show resolved Hide resolved
table_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@Jorropo Jorropo left a comment

Choose a reason for hiding this comment

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

I agree with @MarcoPolo your use .min is weird and require to know it's side effects, I would consider changing it. You can keep it like this because this was how the code you copied it from already worked.

@p-shahi p-shahi removed their request for review June 6, 2023 16:37
Co-authored-by: Jorropo <jorropo.pgm@gmail.com>
@guillaumemichel guillaumemichel merged commit 0f7f61b into master Jun 7, 2023
@guillaumemichel guillaumemichel deleted the feat/useful-peer branch June 7, 2023 06:56
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.

3 participants