-
Notifications
You must be signed in to change notification settings - Fork 2
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: mdns & dht discovery #11
Conversation
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.
Thanks Seth, I did a fairly quick read through and left some comments. I think we need to be careful about race conditions considering that because this is user-event driven this can start and stop at unknown intervals. Also need to clean up events, and maybe parallelize promises for start and stop since both hyperswarm and mdns can take a while and would be better if they initialize / stop at the same time rather than sequentially.
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.
Great work on this. I'd love to hop on a call so you can talk me through some of this - there are parts that I don't quite understand. My questions (likely due to not fully understanding the code):
- Are we broadcasting a new mdns service for each topic? All on the same port? And a single connection for all topics? I wasn't clear what is happening with the peer disconnects and leaving some topics (but not all topics).
- Where are we deduping mdns connections (e.g. there will be an incoming and outgoing connection - Hyperswarm seems to do that here: https://github.com/hyperswarm/hyperswarm/blob/master/index.js#L224-L235
- Race conditions in async methods like join and leave can be common (based on prior experience with the app) due to users being able to switch rapidly between screens and in and out of the app (which causes join and leave actions). I haven't thoroughly reviewed the tests, but I want to make sure we correctly handle the "joining", "leaving", "destroying" states etc. if they do exist - think about the whole thing in terms of a state machine and what possible states exist and what might happen when methods are called in some of these "intermediary" states that happen during an async function.
It would be good to think about the boundaries in mapeo-core between the different modules - thinking as if we would publish as a separate module. My understanding is that the "public" interface (i.e. the interface used by the rest of mapeo core) for discovery is the |
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.
Great work on this. I don't quite understand how topics work for incoming connections on mdns, could we schedule some time so that you can talk me through this?
@gmaclennan I think this is ready now unless there's anything else we should get in to this pr. I made a few issues that seem best handled in follow-up prs: |
This pr implements a wrapper module around mdns-sd-discovery and hyperswarm to provide peer discovery through mdns and dht with one api.