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

protocols/dcutr/example: Wait for relay to accept reservation request #2642

Merged
merged 6 commits into from
May 19, 2022

Conversation

mxinden
Copy link
Member

@mxinden mxinden commented May 11, 2022

Description

When in listening mode, wait for the relay to accept our reservation
request. Only then can a client in dialing mode establish a relayed
connection to us via the relay.

Links to any relevant issues

Might help with #2621 (comment).

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

When in listening mode, wait for the relay to accept our reservation
request. Only then can a client in dialing mode establish a relayed
connection to us via the relay.

See also
libp2p#2621 (comment)
@mxinden
Copy link
Member Author

mxinden commented May 11, 2022

//CC @Foemass

@mxinden
Copy link
Member Author

mxinden commented May 16, 2022

@elenaf9 @thomaseizinger can one of you give this a review?

})) => {
info!("Relay accepted our reservation request.");
relay_accepted_reservation = true
}
SwarmEvent::Behaviour(Event::Relay(_)) => {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also catch the case of client::Event::ReservationReqFailed and return an error in that case.
Shouldn't happen in practice but I'd rather have an explicit error than a non-terminating program.
Alternatively, I think there is no valid case in which any other relay event should occur anyway/ So we could remove the match block here and let it fall to the blank panic below.

Copy link
Contributor

@thomaseizinger thomaseizinger left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 230 to 231
if learned_observed_addr
&& (matches!(opts.mode, Mode::Dial) || relay_accepted_reservation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this be easier to understand if we matched explicitly on Mode and returned true for dial and relay_accepted_reservation for listen?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think of 75697c2?

Copy link
Contributor

Choose a reason for hiding this comment

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

Much better, thank you!

@mxinden mxinden merged commit 0e9ab1c into libp2p:master May 19, 2022
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.

3 participants