-
Notifications
You must be signed in to change notification settings - Fork 939
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
feat(share/discovery): Add callback on peers set updates. #1609
Conversation
a61c997
to
75e05ea
Compare
fc2ca14
to
586ea49
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.
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
33c6d5e
to
986a21f
Compare
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. |
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 I would prefer the callback taking two args instead of a struct, but that is entirely up to you
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.
beautiful.
Co-authored-by: Ryan <ryan@celestia.org>
c0722c9
to
02ae2df
Compare
…g#1609) notify Discovery clients about peers set changes in async manner by calling provided callback. Co-authored-by: Ryan <ryan@celestia.org>
…g#1609) notify Discovery clients about peers set changes in async manner by calling provided callback. Co-authored-by: Ryan <ryan@celestia.org>
…g#1609) notify Discovery clients about peers set changes in async manner by calling provided callback. Co-authored-by: Ryan <ryan@celestia.org>
Overview
Notify Discovery clients about peers set changes in async manner by calling provided callback.
(ps *limitedSet)Peers
method splitted into two funcs:ListPeers
andWaitPeer
, so callback is not locked in case there are no peers.Closes #1610
Checklist