Skip to content

Commit 2ce6a73

Browse files
authored
chore(iroh): Update n0-watcher (#3405)
## Description Updates the `n0-watcher` dependency to the new version (that has a lot fewer `Result`s everywhere). - [x] Depends on n0-computer/net-tools#31 - [x] Needs a release of `net-tools` ## Breaking Changes - Updated `n0-watcher` from version `0.2` to `0.3`. Migration guide for users: - `endpoint.node_addr().initialized().await?` -> `endpoint.node_addr().initialized().await` (no `?` needed anymore) and similarly for `endpoint.home_relay()` and other uses of `Watcher`s. - `endpoint.node_addr().get()?` -> `endpoint.node_addr().get()` and similarly for `endpoint.home_relay()` and other uses of `Watcher`s. - If all you have is a `&impl Watcher` but you need the current value, then you can't call `Watcher::get` anymore, as that now takes a `&mut self` instead of `&self`. You can work around this by `.clone()`ing to an intermediate watcher: `watcher_ref.get()` -> `watcher_ref.clone().get()` ## Change checklist <!-- Remove any that are not relevant. --> - [x] Self-review. - [x] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [x] All breaking changes documented.
1 parent 75fd57c commit 2ce6a73

File tree

17 files changed

+113
-89
lines changed

17 files changed

+113
-89
lines changed

Cargo.lock

Lines changed: 50 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

iroh/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ iroh-base = { version = "0.90.0", default-features = false, features = ["key", "
4141
iroh-relay = { version = "0.90", path = "../iroh-relay", default-features = false }
4242
n0-future = "0.1.2"
4343
n0-snafu = "0.2.1"
44-
n0-watcher = "0.2"
44+
n0-watcher = "0.3"
4545
nested_enum_utils = "0.2.1"
46-
netwatch = { version = "0.7" }
46+
netwatch = { version = "0.8" }
4747
pin-project = "1"
4848
pkarr = { version = "3.7", default-features = false, features = [
4949
"relays",

iroh/bench/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ iroh = { path = ".." }
1212
iroh-metrics = "0.35"
1313
n0-future = "0.1.1"
1414
n0-snafu = "0.2.0"
15-
n0-watcher = "0.2"
1615
quinn = { package = "iroh-quinn", version = "0.14" }
1716
rand = "0.8"
1817
rcgen = "0.14"

iroh/bench/src/iroh.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ use std::{
55

66
use bytes::Bytes;
77
use iroh::{
8-
Endpoint, NodeAddr, RelayMode, RelayUrl,
8+
Endpoint, NodeAddr, RelayMode, RelayUrl, Watcher as _,
99
endpoint::{Connection, ConnectionError, RecvStream, SendStream, TransportConfig},
1010
};
1111
use n0_snafu::{Result, ResultExt};
12-
use n0_watcher::Watcher as _;
1312
use tracing::{trace, warn};
1413

1514
use crate::{
@@ -50,7 +49,7 @@ pub fn server_endpoint(
5049
.unwrap();
5150

5251
if relay_url.is_some() {
53-
ep.home_relay().initialized().await.unwrap();
52+
ep.home_relay().initialized().await;
5453
}
5554

5655
let addr = ep.bound_sockets();
@@ -111,7 +110,7 @@ pub async fn connect_client(
111110
.unwrap();
112111

113112
if relay_url.is_some() {
114-
endpoint.home_relay().initialized().await?;
113+
endpoint.home_relay().initialized().await;
115114
}
116115

117116
// TODO: We don't support passing client transport config currently

iroh/examples/connect-unreliable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async fn main() -> n0_snafu::Result<()> {
5252
.bind()
5353
.await?;
5454

55-
let node_addr = endpoint.node_addr().initialized().await?;
55+
let node_addr = endpoint.node_addr().initialized().await;
5656
let me = node_addr.node_id;
5757
println!("node id: {me}");
5858
println!("node listening addresses:");

iroh/examples/connect.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,13 @@ async fn main() -> Result<()> {
5555
let me = endpoint.node_id();
5656
println!("node id: {me}");
5757
println!("node listening addresses:");
58-
for local_endpoint in endpoint
59-
.direct_addresses()
60-
.initialized()
61-
.await
62-
.context("no direct addresses")?
63-
{
58+
for local_endpoint in endpoint.direct_addresses().initialized().await {
6459
println!("\t{}", local_endpoint.addr)
6560
}
6661

6762
let relay_url = endpoint
6863
.home_relay()
6964
.get()
70-
.unwrap()
7165
.first()
7266
.cloned()
7367
.expect("should be connected to a relay server, try calling `endpoint.local_endpoints()` or `endpoint.connect()` first, to ensure the endpoint has actually attempted a connection before checking for the connected relay server");

iroh/examples/echo-no-router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ALPN: &[u8] = b"iroh-example/echo/0";
2020
#[tokio::main]
2121
async fn main() -> Result<()> {
2222
let endpoint = start_accept_side().await?;
23-
let node_addr = endpoint.node_addr().initialized().await?;
23+
let node_addr = endpoint.node_addr().initialized().await;
2424

2525
connect_side(node_addr).await?;
2626

iroh/examples/echo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ALPN: &[u8] = b"iroh-example/echo/0";
2323
#[tokio::main]
2424
async fn main() -> Result<()> {
2525
let router = start_accept_side().await?;
26-
let node_addr = router.endpoint().node_addr().initialized().await?;
26+
let node_addr = router.endpoint().node_addr().initialized().await;
2727

2828
connect_side(node_addr).await?;
2929

iroh/examples/listen-unreliable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async fn main() -> Result<()> {
3737
println!("node id: {me}");
3838
println!("node listening addresses:");
3939

40-
let node_addr = endpoint.node_addr().initialized().await?;
40+
let node_addr = endpoint.node_addr().initialized().await;
4141
let local_addrs = node_addr
4242
.direct_addresses
4343
.into_iter()

iroh/examples/listen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async fn main() -> n0_snafu::Result<()> {
4242
let local_addrs = endpoint
4343
.direct_addresses()
4444
.initialized()
45-
.await?
45+
.await
4646
.into_iter()
4747
.map(|addr| {
4848
let addr = addr.addr.to_string();
@@ -51,7 +51,7 @@ async fn main() -> n0_snafu::Result<()> {
5151
})
5252
.collect::<Vec<_>>()
5353
.join(" ");
54-
let relay_url = endpoint.home_relay().initialized().await?;
54+
let relay_url = endpoint.home_relay().initialized().await;
5555
println!("node relay server url: {relay_url}");
5656
println!("\nin a separate terminal run:");
5757

0 commit comments

Comments
 (0)