Skip to content

feat(iroh-relay)!: adjust APIs to make it easier to create RelayMaps from lists of RelayUrls #3292

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

Merged
merged 8 commits into from
May 8, 2025

Conversation

ramfox
Copy link
Contributor

@ramfox ramfox commented May 6, 2025

Description

In our examples and tests, it is enough to build RelayMaps from a single RelayUrl, but our users will more likely be in the situation where they have multiple relays.

Now we have From<RelayUrl>, From<(RelayUrl, u16)>, FromIterator<RelayUrl> FromIterator<(RelayUrl, u16)> impls to create a RelayMap.

Also, From<RelayUrl> and From<(RelayUrl, u16)> to create a RelayNode.

Breaking Changes

  • iroh
    • remove
      • pub fn default_from_node(url: RelayUrl, stun_port: u16) -> RelayMap
    • change
      • pub fn from_url(url: RelayUrl) -> RelayMap, use From<RelayUrl> instead

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • All breaking changes documented.
    • List all breaking changes in the above "Breaking Changes" section.

… from lists of `RelayUrls`

In our examples and tests, it is enough to build `RelayMap`s from a single `RelayUrl`, but our users will more likely be in the situation where they have multiple relays. This changes the APIs to make adding multiple relays the most prominant use case.
Copy link

github-actions bot commented May 6, 2025

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

Last updated: 2025-05-07T16:18:39Z

Copy link

github-actions bot commented May 6, 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: 25a8cd7

@ramfox ramfox changed the title feat(iroh-relay): adjust APIs to make it easier to create RelayMaps from lists of RelayUrls feat(iroh-relay)!: adjust APIs to make it easier to create RelayMaps from lists of RelayUrls May 6, 2025
@ramfox ramfox requested review from flub, dignifiedquire and matheus23 and removed request for flub and dignifiedquire May 6, 2025 16:40
@flub
Copy link
Contributor

flub commented May 6, 2025

I think it is great to be sleuthing at these APIs! They are indeed not very ergonomic. Would they not be more rusty by leveraging traits more?

  • Instead of from_url use From<RelayUrl>
  • Instead of default_from_nodes use FromIterator<(RelayUrl, u16)>
  • Instead of from_urls use FromIterator<RelayUrl>
  • Instead of from_nodes use FromIterator<Arc<RelayNode>>. Actually, what is going on with that constructor? It has an Into<Arc<RelayNode>> already.

I'm kind of curious why they grew into what they currently are, so might be missing the mark.

Edit: The doc comments on all the functions are also fairly over the place and need fixing.

@n0bot n0bot bot added this to iroh May 6, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh May 6, 2025
@ramfox ramfox force-pushed the ramfox/relay-map branch from aa66be1 to 3daa4b5 Compare May 6, 2025 20:49
@ramfox ramfox force-pushed the ramfox/relay-map branch from 3daa4b5 to 4a853a2 Compare May 6, 2025 20:51
@ramfox
Copy link
Contributor Author

ramfox commented May 6, 2025

Did everything suggested in @flub your comment, but adjusted the code to remove the need for the Arc in FromIterator<Arc<RelayNode>> for RelayMap

ramfox and others added 5 commits May 7, 2025 12:08
Co-authored-by: Floris Bruynooghe <[email protected]>
Co-authored-by: Floris Bruynooghe <[email protected]>
Co-authored-by: Floris Bruynooghe <[email protected]>
Co-authored-by: Floris Bruynooghe <[email protected]>
…t we also have a QUIC port to configure, having an impl that only looks at the STUN port does not make sense
Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

The "Breaking Changes" section in the PR description needs updating, but otherwise looks good!

@ramfox ramfox added this pull request to the merge queue May 8, 2025
Merged via the queue into main with commit cd0a47a May 8, 2025
29 of 30 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh May 8, 2025
@ramfox ramfox deleted the ramfox/relay-map branch May 14, 2025 16:50
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