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 callback on peers set updates. #1609

Merged
merged 6 commits into from
Jan 20, 2023

Conversation

walldiss
Copy link
Member

@walldiss walldiss commented Jan 17, 2023

Overview

Notify Discovery clients about peers set changes in async manner by calling provided callback.

(ps *limitedSet)Peers method splitted into two funcs: ListPeers and WaitPeer, so callback is not locked in case there are no peers.

Closes #1610

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

@walldiss walldiss force-pushed the discovery_on_peers_update branch from a61c997 to 75e05ea Compare January 17, 2023 12:30
@walldiss walldiss self-assigned this Jan 17, 2023
@walldiss walldiss force-pushed the discovery_on_peers_update branch 4 times, most recently from fc2ca14 to 586ea49 Compare January 17, 2023 12:55
@walldiss walldiss marked this pull request as ready for review January 17, 2023 12:58
@Wondertan Wondertan changed the title improvement(share/discovery): Add callback on peers set updates. feat(share/discovery): Add callback on peers set updates. Jan 17, 2023
Wondertan
Wondertan previously approved these changes Jan 17, 2023
share/availability/discovery/discovery.go Outdated Show resolved Hide resolved
share/availability/discovery/discovery.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@distractedm1nd distractedm1nd left a comment

Choose a reason for hiding this comment

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

One question: why send all peers through onPeersUpdate since it's called in handlePeerFound? Can't we just name it onPeerFound/OnPeerFound and only send in the new peer? And I agree with hlib that it might be better with a channel, if you agree (but really optional)

Also needs a test

share/availability/discovery/discovery.go Outdated Show resolved Hide resolved
share/availability/discovery/set.go Outdated Show resolved Hide resolved
@walldiss
Copy link
Member Author

Updated with @distractedm1nd suggestion to only emit diff, not the full peers list. This removes some changes in set.go and in tests. As a note: callback provider will needs to be careful with keeping state up to date so it don't diverge from discovery one.

Copy link
Collaborator

@distractedm1nd distractedm1nd left a comment

Choose a reason for hiding this comment

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

I think I would prefer the callback taking two args instead of a struct, but that is entirely up to you

share/availability/discovery/discovery.go Outdated Show resolved Hide resolved
share/availability/discovery/discovery.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@distractedm1nd distractedm1nd left a comment

Choose a reason for hiding this comment

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

beautiful.

@walldiss walldiss force-pushed the discovery_on_peers_update branch from c0722c9 to 02ae2df Compare January 20, 2023 11:06
@walldiss walldiss merged commit 7305099 into celestiaorg:main Jan 20, 2023
jpserrat pushed a commit to jpserrat/celestia-node that referenced this pull request Jan 23, 2023
…g#1609)

notify Discovery clients about peers set changes in async manner by
calling provided callback.

Co-authored-by: Ryan <ryan@celestia.org>
distractedm1nd added a commit to distractedm1nd/celestia-node that referenced this pull request Jan 26, 2023
…g#1609)

notify Discovery clients about peers set changes in async manner by
calling provided callback.

Co-authored-by: Ryan <ryan@celestia.org>
renaynay pushed a commit to renaynay/celestia-node that referenced this pull request Jan 31, 2023
…g#1609)

notify Discovery clients about peers set changes in async manner by
calling provided callback.

Co-authored-by: Ryan <ryan@celestia.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:shares Shares and samples
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

improvement(share/discovery): Add async API on peers set changes.
4 participants