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

fix(relay/client): only try to forward handler events once #5765

Merged
merged 9 commits into from
Jan 27, 2025

Conversation

elenaf9
Copy link
Contributor

@elenaf9 elenaf9 commented Dec 25, 2024

Description

We currently try to forward pending handler events in the relay client behavior twice: in handle_established_{in, out}bound_connection and in on_swarm_event() (introduced in #3328).
This is redundant because by the second time we try to forward it there won't be any pending event anymore.
This PR removes the duplicated logic from on_swarm_event. Forwarding it in handle_established_{in, out}bound_connection is more convenient as we still have direct access to the handler there and don't need to go through the swarm.

However, it requires that in handle_established_{in, out}bound_connection the event is also removed when the connection is relayed, in which case the event is simply discarded because the commands are only valid on direct connections.

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

@elenaf9 elenaf9 changed the title fix(relay/client): only send handler commands on direct connections fix(relay/client): only try to forward handler events once Dec 25, 2024
@elenaf9 elenaf9 requested a review from jxs January 13, 2025 13:03
Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Nice catch Elena LGTM!

protocols/relay/src/priv_client.rs Show resolved Hide resolved
@jxs jxs added the send-it label Jan 27, 2025
@mergify mergify bot merged commit 68ea5b7 into libp2p:master Jan 27, 2025
71 checks passed
@elenaf9 elenaf9 deleted the relay/fix-forwarding-handler-commands branch January 27, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants