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)!: Wrap the Connection struct so we own the type #3110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

flub
Copy link
Contributor

@flub flub commented Jan 9, 2025

Description

This makes iroh own the Connection type. This is desireable because:

  • Some: upstream APIs don't work well for us,
    e.g. Connection::remote_address is not that meaningful. This allows
    us to remove those and replace them with more appropriate APIs. This
    has not yet been done in this PR however.

  • The connection type and changes are currently on the Endpoint, they
    also belong on the Connection.

  • Connection information, like which pats are used, the latencies of
    those paths etc, also belong on the Connection.

  • It is generally not great to expose types which you have no control
    over in your public API. For the 1.0 we do not want to have any
    such structs. This takes an important step in that direction.

As part of this change Connection::remote_node_id replaces the
get_remote_node_id function. Also Connection::alpn now exists.

Breaking Changes

iroh

  • iroh::endpoint::get_remote_node_id has been removed. Use
    iroh::endpoint::Connection::remote_node_id instead.

Notes & open questions

This does not yet clean up the existing methods in the Connection,
preserving most of them as-is. It is easier to handle those
separately as each one involves careful decisions about the API.

Replaces #2768

Change checklist

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

This makes iroh own the Connection type.  This is desireable because:

- Some: upstream APIs don't work well for us,
  e.g. Connection::remote_address is not that meaningful.  This allows
  us to remove those and replace them with more appropriate APIs.  This
  has not yet been done in this PR however.

- The connection type and changes are currently on the Endpoint, they
  also belong on the Connection.

- Connection information, like which pats are used, the latencies of
  those paths etc, also belong on the Connection.

- It is generally not great to expose types which you have no control
  over in your public API.  For the 1.0 we do not want to have any
  such structs.  This takes an important step in that direction.

As part of this change Connection::remote_node_id replaces the
get_remote_node_id function.  Also Connection::alpn now exists.
@flub flub requested a review from a team January 9, 2025 11:04
Copy link

github-actions bot commented Jan 9, 2025

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

Last updated: 2025-01-09T11:05:55Z

Copy link

github-actions bot commented Jan 9, 2025

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: 2fbb489

@matheus23 matheus23 added this to the v0.31.0 milestone Jan 9, 2025
/// connection.
///
/// [`PublicKey`]: iroh_base::PublicKey
// TODO: Would be nice if this could be infallible.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there cases where we expect this to be fallible?
Why not make this infallible by using self.peer_identity().unwrap()?
Is returning an error here a boneheaded exception?

Copy link
Contributor

@matheus23 matheus23 left a comment

Choose a reason for hiding this comment

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

I really like this.

I'd personally love to go even further and remove Connection::remote_address already, etc. but I get that you're going to do that as follow-ups instead.

@flub flub self-assigned this Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

2 participants