-
Notifications
You must be signed in to change notification settings - Fork 919
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(share/discovery): add Peers method #1451
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1451 +/- ##
==========================================
- Coverage 56.02% 55.47% -0.55%
==========================================
Files 188 197 +9
Lines 11551 11997 +446
==========================================
+ Hits 6471 6655 +184
- Misses 4443 4683 +240
- Partials 637 659 +22
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
c87096f
to
d59542b
Compare
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.
Note for everyone. This design has one problem, it does not allow us to get newly discovered peers in real-time, so protocols relying on it won't get them without retries. We are going this way for simplicity first and can improve with further iterations of the protocol.
6c7c120
to
f80c7e0
Compare
Co-authored-by: Ryan <ryan@celestia.org>
ad713bf
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.
just some doc requests, otherwise gtg
@@ -61,12 +71,24 @@ func (ps *limitedSet) Remove(id peer.ID) { | |||
} | |||
} | |||
|
|||
func (ps *limitedSet) Peers() []peer.ID { | |||
// Peers returns all discovered peers from the set. |
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.
I think it is worth mention in comment that Peer() will block if not peers are available until either ctx is Done or new peer discovered
select { | ||
case ps.waitPeer <- p: | ||
default: | ||
} |
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.
Looks like if there are multiple waiters we will only notify one. I suggest for loop with return in default case of select.
Nit: Could refactor it to return error earlier and then.
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview Improvement for #1451 Notify multiple readers instead of one. ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [x] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [x] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords
## Overview Resolves celestiaorg#1449 ## Checklist - [x] New and updated code has appropriate documentation - [x] New and updated code has new and/or updated testing - [x] Required CI checks are passing - [x] Visual proof for any user facing features like CLI or documentation updates - [x] Linked issues closed with keywords Co-authored-by: Ryan <ryan@celestia.org>
Overview
Resolves #1449
Checklist