-
Notifications
You must be signed in to change notification settings - Fork 313
refactor: minor cleanups in endpoint state #3626
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
Conversation
|
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3626/docs/iroh/ Last updated: 2025-11-10T09:17:44Z |
flub
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think the path_remote helper can be a bit better still but good improvements!
| if let Some(path) = conn.path(PathId::ZERO) | ||
| && let Some(path_remote) = path_remote(&self.relay_mapped_addrs, &path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL you can combine let Some(x) bindings like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's really nice. It's quite new, added in 2024 edition.
| } | ||
| } | ||
|
|
||
| fn path_remote( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc comment please.
I've gone back and forth on this. I used to have a helper for this at some point :) But I never like this kind of helper that just takes a bunch of random things by ref.
What about:
impl AddrMap<(RelayUrl, EndpointId), RelayMappedAddr> {
/// Convert a mapped socket address to a transport addr.
///
/// To map to a [`transports::Addr`] only the [`RelayMappedAddr`] needs to be able to be
/// looked up. So we can have this as a helper here.
fn to_transport_addr(&self, sockaddr: SocketAddr) -> Option<transports::Addr> {
MultipathMappedAddr::from(sockaddr).to_transport_addr(self)
}
}And probably MultipathMappedAddr::to_transport_addr should be removed and merged into this impl. It's just going to sow confusion over there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also always been a little on the fence on whether creating the AddrMap was a useful abstraction level. I'm not that sure.
I think now I'd try and make a single AddrMap struct (not trait) that contained both the mapped addrs in a single lock. It would be a much more natural place for this conversion to live. But anyway, we're here now and this isn't the most blocking thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm! pushed this.
Description
This has a few minor cleanups without any functional changes in the endpoint state actor:
to_transport_addron the relay mapped addr mapentryAPI instead ofgetandexpectif letchains to remove a level of indentationBreaking Changes
Notes & open questions
Change checklist
quic-rpciroh-gossipiroh-blobsdumbpipesendme