-
Notifications
You must be signed in to change notification settings - Fork 141
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
refactor(*): rework NodeAddr
#1506
refactor(*): rework NodeAddr
#1506
Conversation
iroh-net/src/magic_endpoint.rs
Outdated
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct NodeAddr { | ||
pub struct PeerData { |
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.
About the name - What about PeerAddr
? To me having addr
in there suggests "this is what you need to connect", which is what it is. So if we decided for Peer
, not Node
, then I'd say let's do PeerAddr
.
And then maybe have info: AddrInfo
, without the addr_
prefix.
iroh-net/src/magic_endpoint.rs
Outdated
) -> Result<quinn::Connection> { | ||
self.add_known_addrs(node_id, derp_region, known_addrs) | ||
.await?; | ||
pub async fn connect(&self, peer_data: PeerData, alpn: &[u8]) -> Result<quinn::Connection> { |
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 think here peer_addr: PeerAddr
reads much nicer than PeerData
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.
Approving, with the suggestion to change the naming to PeerAddr
or similar.
Finer details or further can be done in followups but let's get the actual change in to have a combined type we use in the interface 👍
iroh-net/src/magic_endpoint.rs
Outdated
endpoints: endpoints.to_vec(), | ||
}; | ||
self.msock.add_known_addr(addr).await?; | ||
pub async fn add_peer_data(&self, peer_data: PeerData) -> Result<()> { |
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.
This could be add_peer_addr
with the other suggested rename, which sounds fine to me too.
…able tests (#1513) ## Description * **fix(gossip): properly encode peer data.** #1506 introduced a bug: The `PeerData` was encoded from the `PeerAddr` (including the peer id) but decoded to `AddrInfo` (without the peer id). So it failed, and dialing peers failed. It only did not matter much because most tests use tickets separately, so do not rely on the `PeerData` gossip. * **feat: expose neighbor events** through document subscriptions. for now used to write better and less flakey tests. also useful for stats like usecases, and potentially others. * **tests: improve sync tests** and make `sync_full_basic` not flakey anymore (hopefully). the main change is that for some events, we don't care about the exact order in tests anymore, because the exact order is too unpredictable timing-wise for things that happen concurrently. instead they are matched in chunks. ## Change checklist - [x] Self-review. - [x] Documentation updates if relevant. - [x] Tests if relevant. Replaces #1512
Description
AddrInfo
that contains the addressing information of peers. This is necessary as it's own type since it's serialized both in gossip and in feat(iroh-net): persist known peer info #1488NodeAddr
toPeerData
(better name suggestions are well received) this helps consolidate the "peer" terminology already present throughout gossip, sync, downloader, and many other placesiroh_net::PeerAddr
more #1493Notes & open questions
This applies the suggestion of doing
connect
using the full type. It's debatable if this is better thanconnect(PublicKey, AddrInfo)
but both are imo an improvement over the current way since the idea if "what does iroh need to connect to a peer" is now fully described in a typeChange checklist