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(mdns): emit ToSwarm::NewExternalAddrOfPeer #5179

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

justcode740
Copy link

@justcode740 justcode740 commented Feb 21, 2024

Description

Resolves #5104

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@justcode740 justcode740 changed the title ch feat(mdns): Feb 21, 2024
@justcode740 justcode740 changed the title feat(mdns): feat(mdns): emit ToSwarm::NewExternalAddrOfPeer Feb 21, 2024
@@ -347,8 +347,10 @@ where
}

if !discovered.is_empty() {
let event = Event::Discovered(discovered);
return Poll::Ready(ToSwarm::GenerateEvent(event));
return Poll::Ready(ToSwarm::NewExternalAddrOfPeer {
Copy link

Choose a reason for hiding this comment

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

[question]

Sorry if this is a silly question, I'm new to both rust and the libp2p code base.

  1. This seems like a breaking change for any code base that currently relies on Event::Discovered

Is my understanding of rust breaking changes right here?

Would it be worth preserving Event::Discovered here for backwards compatibility?

  1. This only emits the first discovered peer

Reading lines 333-345, it looks like the Poll event will keep going until it drains query_response_receiver, discovering multiple peers?

This seems like we would want to return a ToSwarm::NewExternalAddrOfPeer for every peer we discover on line 345.

Should this move up to line 345 and replace the discovered vec?

  1. I acknowledge that, as written, point 2 might be at odds with point 1 😅.

To have our cake, and eat it too, could 333-347 be moved out of fn poll and instead feed two receivers, one that sends Event::Discovered after all ToSwarm::NewExternalAddrOfPeers have been flushed and the other that sends each ToSwarm::NewExternalAddrOfPeer?

Copy link
Member

Choose a reason for hiding this comment

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

yeah exactly, thanks @retrohacker!
You can see the upnp example on how to return both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mDNS: emit ToSwarm::NewExternalAddrOfPeer
3 participants