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(iroh-net)!: Allow using a NodeId directly in connect. #2774

Merged
merged 6 commits into from
Oct 2, 2024

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Oct 2, 2024

Description

Allow using anything can be converted to a NodeAddr when connecting. This means that we can directly connect with NodeIds, and connect_by_node_id is no longer needed.

Also deprecate connect_by_node_id since it is no longer needed.

Breaking Changes

  • iroh-net: Endpoint::connect now takes an impl Into<NodeAddr> instead of a NodeAddr
  • iroh-net: Endpoint::connect_by_node_id is deprecated (to be removed next release)

Notes & open questions

Note: Doing this means that the instrumentation of connect no longer contains the remote, which is bad I guess. Not sure how to work around this. One way would be to have connect and connect_impl - connect_impl is like the current connect and can be instrumented as before. Any other way to do this?

Note: since there is a From for NodeAddr, you can also directly dial using a ticket, which is kinda neat.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

Also deprecate connect_by_node_id since it is no longer needed.
@rklaehn rklaehn requested a review from flub October 2, 2024 09:27
@rklaehn rklaehn changed the title Allow using a NodeId directly in connect. feat(iroh-net)!: Allow using a NodeId directly in connect. Oct 2, 2024
Copy link

github-actions bot commented Oct 2, 2024

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/2774/docs/iroh/

Last updated: 2024-10-02T12:18:06Z

Copy link

github-actions bot commented Oct 2, 2024

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 46d0b87

Copy link
Contributor

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

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

nice, I like it

iroh-net/src/endpoint.rs Show resolved Hide resolved
iroh-net/src/endpoint.rs Show resolved Hide resolved
iroh-net/src/endpoint.rs Outdated Show resolved Hide resolved
@rklaehn rklaehn requested a review from flub October 2, 2024 11:48
@rklaehn rklaehn marked this pull request as ready for review October 2, 2024 12:13
@rklaehn rklaehn added this pull request to the merge queue Oct 2, 2024
Merged via the queue into main with commit bd5e4fa Oct 2, 2024
28 checks passed
@dignifiedquire dignifiedquire deleted the remove-connect-by-node-id branch October 2, 2024 16:22
/// A value that can be converted into a [`NodeAddr`] is required. This can be either a
/// [`NodeAddr`], a [`NodeId`] or a [`iroh_base::ticket::NodeTicket`].
///
/// The [`NodeAddr`] must contain the [`NodeId`] to dial and may also contain a [`RelayUrl`]
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use dial in any of the API names of iroh-net::Endpoint so I prefer not to use that in documentation either as that is probably confusing to users. I usually stick to "connect", "establish a connection" or something like that.

(yeah, there's the somewhat weird dialer module which is a bit of an odd duck...)

alpn: &[u8],
) -> Result<quinn::Connection> {
let node_addr = node_addr.into();
tracing::Span::current().record("remote", node_addr.node_id.fmt_short());
Copy link
Contributor

Choose a reason for hiding this comment

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

that's cool! TIL

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

Successfully merging this pull request may close these issues.

3 participants