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

refactor(iroh-net)!: Rename Endpoint::my_addr to Endpoint::node_addr #2362

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions iroh-gossip/examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ async fn main() -> anyhow::Result<()> {
.await?;
println!("> our node id: {}", endpoint.node_id());

let my_addr = endpoint.my_addr().await?;
let my_addr = endpoint.node_addr().await?;
// create the gossip protocol
let gossip = Gossip::from_endpoint(endpoint.clone(), Default::default(), &my_addr.info);

// print a ticket that includes our own node id and endpoint addresses
let ticket = {
let me = endpoint.my_addr().await?;
let me = endpoint.node_addr().await?;
let peers = peers.iter().cloned().chain([me]).collect();
Ticket { topic, peers }
};
Expand Down
10 changes: 5 additions & 5 deletions iroh-net/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ mod tests {
};
let ep1_addr = NodeAddr::new(ep1.node_id());
// wait for out address to be updated and thus published at least once
ep1.my_addr().await?;
ep1.node_addr().await?;
let _conn = ep2.connect(ep1_addr, TEST_ALPN).await?;
Ok(())
}
Expand All @@ -442,7 +442,7 @@ mod tests {
};
let ep1_addr = NodeAddr::new(ep1.node_id());
// wait for out address to be updated and thus published at least once
ep1.my_addr().await?;
ep1.node_addr().await?;
let _conn = ep2.connect(ep1_addr, TEST_ALPN).await?;
Ok(())
}
Expand Down Expand Up @@ -472,7 +472,7 @@ mod tests {
};
let ep1_addr = NodeAddr::new(ep1.node_id());
// wait for out address to be updated and thus published at least once
ep1.my_addr().await?;
ep1.node_addr().await?;
let _conn = ep2.connect(ep1_addr, TEST_ALPN).await?;
Ok(())
}
Expand All @@ -495,7 +495,7 @@ mod tests {
};
let ep1_addr = NodeAddr::new(ep1.node_id());
// wait for out address to be updated and thus published at least once
ep1.my_addr().await?;
ep1.node_addr().await?;
let res = ep2.connect(ep1_addr, TEST_ALPN).await;
assert!(res.is_err());
Ok(())
Expand All @@ -518,7 +518,7 @@ mod tests {
new_endpoint(secret, disco).await
};
// wait for out address to be updated and thus published at least once
ep1.my_addr().await?;
ep1.node_addr().await?;
let ep1_wrong_addr = NodeAddr {
node_id: ep1.node_id(),
info: AddrInfo {
Expand Down
10 changes: 5 additions & 5 deletions iroh-net/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ impl Endpoint {
/// The returned [`NodeAddr`] will have the current [`RelayUrl`] and local IP endpoints
/// as they would be returned by [`Endpoint::my_relay`] and
/// [`Endpoint::local_endpoints`].
pub async fn my_addr(&self) -> Result<NodeAddr> {
pub async fn node_addr(&self) -> Result<NodeAddr> {
let addrs = self
.local_endpoints()
.next()
Expand Down Expand Up @@ -1067,7 +1067,7 @@ mod tests {
.bind(0)
.await
.unwrap();
let my_addr = ep.my_addr().await.unwrap();
let my_addr = ep.node_addr().await.unwrap();
let res = ep.connect(my_addr.clone(), TEST_ALPN).await;
assert!(res.is_err());
let err = res.err().unwrap();
Expand Down Expand Up @@ -1341,8 +1341,8 @@ mod tests {
.bind(0)
.await
.unwrap();
let ep1_nodeaddr = ep1.my_addr().await.unwrap();
let ep2_nodeaddr = ep2.my_addr().await.unwrap();
let ep1_nodeaddr = ep1.node_addr().await.unwrap();
let ep2_nodeaddr = ep2.node_addr().await.unwrap();
ep1.add_node_addr(ep2_nodeaddr.clone()).unwrap();
ep2.add_node_addr(ep1_nodeaddr.clone()).unwrap();
let ep1_nodeid = ep1.node_id();
Expand Down Expand Up @@ -1438,7 +1438,7 @@ mod tests {
let ep1_nodeid = ep1.node_id();
let ep2_nodeid = ep2.node_id();

let ep1_nodeaddr = ep1.my_addr().await.unwrap();
let ep1_nodeaddr = ep1.node_addr().await.unwrap();
tracing::info!(
"node id 1 {ep1_nodeid}, relay URL {:?}",
ep1_nodeaddr.relay_url()
Expand Down
2 changes: 1 addition & 1 deletion iroh/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ where

debug!("rpc listening on: {:?}", self.rpc_endpoint.local_addr());

let addr = endpoint.my_addr().await?;
let addr = endpoint.node_addr().await?;

// initialize the gossip protocol
let gossip = Gossip::from_endpoint(endpoint.clone(), Default::default(), &addr.info);
Expand Down
4 changes: 2 additions & 2 deletions iroh/src/node/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ impl<D: BaoStore> Handler<D> {

async fn node_status(self, _: NodeStatusRequest) -> RpcResult<NodeStatus> {
Ok(NodeStatus {
addr: self.inner.endpoint.my_addr().await?,
addr: self.inner.endpoint.node_addr().await?,
listen_addrs: self
.inner
.local_endpoint_addresses()
Expand All @@ -757,7 +757,7 @@ impl<D: BaoStore> Handler<D> {
}

async fn node_addr(self, _: NodeAddrRequest) -> RpcResult<NodeAddr> {
let addr = self.inner.endpoint.my_addr().await?;
let addr = self.inner.endpoint.node_addr().await?;
Ok(addr)
}

Expand Down
2 changes: 1 addition & 1 deletion iroh/src/node/rpc/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ impl DocsEngine {
mode,
addr_options,
} = req;
let mut me = self.endpoint.my_addr().await?;
let mut me = self.endpoint.node_addr().await?;
me.apply_options(addr_options);

let capability = match mode {
Expand Down
Loading