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(share/discovery): add Peers method #1451

Merged
merged 5 commits into from
Dec 9, 2022

Conversation

vgonkivs
Copy link
Member

@vgonkivs vgonkivs commented Dec 7, 2022

Overview

Resolves #1449

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@vgonkivs vgonkivs added area:p2p kind:feat Attached to feature PRs labels Dec 7, 2022
@vgonkivs vgonkivs self-assigned this Dec 7, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2022

Codecov Report

Merging #1451 (ad713bf) into main (da4f54b) will decrease coverage by 0.54%.
The diff coverage is 81.81%.

@@            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     
Impacted Files Coverage Δ
share/availability/discovery/discovery.go 31.63% <0.00%> (-0.66%) ⬇️
share/availability/discovery/set.go 90.38% <90.00%> (-1.93%) ⬇️
share/share.go 54.54% <0.00%> (-45.46%) ⬇️
nodebuilder/p2p/p2p.go 51.11% <0.00%> (-34.08%) ⬇️
nodebuilder/share/module.go 77.08% <0.00%> (-17.92%) ⬇️
header/p2p/options.go 64.89% <0.00%> (-5.60%) ⬇️
api/rpc/server.go 61.40% <0.00%> (-1.64%) ⬇️
header/p2p/subscription.go 77.27% <0.00%> (-0.99%) ⬇️
share/eds/eds.go 67.25% <0.00%> (ø)
... and 24 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Wondertan
Wondertan previously approved these changes Dec 8, 2022
Copy link
Member

@Wondertan Wondertan left a 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.

share/availability/discovery/discovery.go Outdated Show resolved Hide resolved
Wondertan
Wondertan previously approved these changes Dec 8, 2022
distractedm1nd
distractedm1nd previously approved these changes Dec 8, 2022
share/availability/discovery/set_test.go Outdated Show resolved Hide resolved
Co-authored-by: Ryan <ryan@celestia.org>
Wondertan
Wondertan previously approved these changes Dec 8, 2022
Copy link
Member

@renaynay renaynay left a 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

share/availability/discovery/set.go Show resolved Hide resolved
share/availability/discovery/set_test.go Show resolved Hide resolved
@vgonkivs vgonkivs merged commit b5eeaa3 into celestiaorg:main Dec 9, 2022
@@ -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.
Copy link
Member

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

Comment on lines +56 to +59
select {
case ps.waitPeer <- p:
default:
}
Copy link
Member

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.

vgonkivs added a commit that referenced this pull request Dec 9, 2022
<!--
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
renaynay pushed a commit to renaynay/celestia-node that referenced this pull request Dec 9, 2022
## 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>
@vgonkivs vgonkivs deleted the extend_discovery branch January 9, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:p2p kind:feat Attached to feature PRs
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

discovery: Add Peers method
6 participants