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

feat!: ping peers before adding to routing table #2745

Merged
merged 4 commits into from
Oct 3, 2024

Conversation

achingbrain
Copy link
Member

Implements the check-before-add client optimisation to ping a peer before adding it to the routing table.

Adds a "new peer ping queue" to apply a concurrency limit to these pings, because it would be expected for old contacts to be less likely to be online so don't block adding new contacts to unrelated buckets if the connection to an old contact is timing out while being pinged before eviction.

BREAKING CHANGE: the routing ping options have been split into "old contact" and "new contact" and renamed according

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

Implements the [check-before-add](https://github.com/libp2p/go-libp2p-kad-dht/blob/master/optimizations.md#checking-before-adding)
client optimisation to ping a peer before adding it to the routing
table.

Adds a "new peer ping queue" to apply a concurrency limit to these
pings, because it would be expected for old contacts to be less
likely to be online so don't block adding new contacts to unrelated
buckets if the connection to an old contact is timing out while
being pinged before eviction.

BREAKING CHANGE: the routing ping options have been split into "old contact" and "new contact" and renamed according
@achingbrain achingbrain requested a review from a team as a code owner October 2, 2024 10:30
Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

Look good overall, I left some comments as I do wonder if a consumer would be able to immediately understand what these new parameters are used for.

Also should we add a migration guide outlining these new params?

packages/kad-dht/src/index.ts Show resolved Hide resolved
packages/kad-dht/src/index.ts Show resolved Hide resolved
Copy link
Member

@maschad maschad left a comment

Choose a reason for hiding this comment

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

Nice work

@achingbrain achingbrain merged commit 661d658 into main Oct 3, 2024
21 checks passed
@achingbrain achingbrain deleted the feat/check-peers-before-adding-to-table branch October 3, 2024 11:38
@achingbrain achingbrain mentioned this pull request Oct 3, 2024
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.

2 participants