Skip to content

Commit 253a8c6

Browse files
authored
chore: update to latest iroh (#77)
## Description Adjust `iroh-blobs` to work with latest `iroh`, `iroh-gossip`, and `quic-rpc`
1 parent 3e9662c commit 253a8c6

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

Diff for: Cargo.lock

+24-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+7-12
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ genawaiter = { version = "0.99.1", features = ["futures03"] }
4040
hashlink = { version = "0.9.0", optional = true }
4141
hex = "0.4.3"
4242
indicatif = { version = "0.17.8", optional = true }
43-
iroh-base = { version = "0.33" }
43+
iroh-base = { version = "0.34" }
4444
iroh-io = { version = "0.6.0", features = ["stats"] }
45-
iroh-metrics = { version = "0.31", default-features = false }
46-
iroh = "0.33"
45+
iroh-metrics = { version = "0.32", default-features = false }
46+
iroh = "0.34"
4747
nested_enum_utils = { version = "0.1.0", optional = true }
4848
num_cpus = "1.15.0"
4949
oneshot = "0.1.8"
@@ -54,8 +54,8 @@ postcard = { version = "1", default-features = false, features = [
5454
"use-std",
5555
"experimental-derive",
5656
] }
57-
quic-rpc = { version = "0.18.3", optional = true }
58-
quic-rpc-derive = { version = "0.18", optional = true }
57+
quic-rpc = { version = "0.19", optional = true }
58+
quic-rpc-derive = { version = "0.19", optional = true }
5959
rand = "0.8"
6060
range-collections = "0.4.0"
6161
redb = { version = "2.2.0", optional = true }
@@ -80,7 +80,7 @@ tracing-test = "0.2.5"
8080

8181
[dev-dependencies]
8282
http-body = "1.0"
83-
iroh = { version = "0.33", features = ["test-utils"] }
83+
iroh = { version = "0.34", features = ["test-utils"] }
8484
quinn = { package = "iroh-quinn", version = "0.13", features = ["ring"] }
8585
futures-buffered = "0.2.4"
8686
proptest = "1.0.0"
@@ -149,7 +149,7 @@ name = "hello-world-provide"
149149
required-features = ["example-iroh"]
150150

151151
[[example]]
152-
name = "local-swarm-discovery"
152+
name = "discovery-local-network"
153153
required-features = ["example-iroh"]
154154

155155
[[example]]
@@ -184,8 +184,3 @@ debug-assertions = false
184184
opt-level = 3
185185
panic = 'abort'
186186
incremental = false
187-
188-
[patch.crates-io]
189-
iroh = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
190-
iroh-base = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
191-
quic-rpc = { git = "https://github.com/n0-computer/quic-rpc", branch = "main" }

Diff for: deny.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ ignore = [
3434
"RUSTSEC-2024-0370", # unmaintained, no upgrade available
3535
"RUSTSEC-2024-0384", # unmaintained, no upgrade available
3636
"RUSTSEC-2024-0436", # unmaintained paste
37-
"RUSTSEC-2025-0012", # unmaintained backoff
3837
]
3938

4039
[sources]
41-
allow-git = [
42-
"https://github.com/n0-computer/iroh.git",
43-
"https://github.com/n0-computer/quic-rpc.git"
44-
]
40+
allow-git = []

Diff for: examples/custom-protocol.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use anyhow::Result;
4444
use clap::Parser;
4545
use futures_lite::future::Boxed as BoxedFuture;
4646
use iroh::{
47-
endpoint::Connecting,
47+
endpoint::Connection,
4848
protocol::{ProtocolHandler, Router},
4949
Endpoint, NodeId,
5050
};
@@ -142,12 +142,10 @@ impl ProtocolHandler for BlobSearch {
142142
///
143143
/// The returned future runs on a newly spawned tokio task, so it can run as long as
144144
/// the connection lasts.
145-
fn accept(&self, connecting: Connecting) -> BoxedFuture<Result<()>> {
145+
fn accept(&self, connection: Connection) -> BoxedFuture<Result<()>> {
146146
let this = self.clone();
147147
// We have to return a boxed future from the handler.
148148
Box::pin(async move {
149-
// Wait for the connection to be fully established.
150-
let connection = connecting.await?;
151149
// We can get the remote's node id from the connection.
152150
let node_id = connection.remote_node_id()?;
153151
println!("accepted connection from {node_id}");

Diff for: examples/local-swarm-discovery.rs renamed to examples/discovery-local-network.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
//! Example that runs and iroh node with local node discovery and no relay server
22
//!
33
//! Run the follow command to run the "accept" side, that hosts the content:
4-
//! $ cargo run --example local_swarm_discovery --features="discovery-local-network" -- accept [FILE_PATH]
4+
//! $ cargo run --example discovery_local_network --features="discovery-local-network" -- accept [FILE_PATH]
55
//! Wait for output that looks like the following:
6-
//! $ cargo run --example local_swarm_discovery --features="discovery-local-network" -- connect [NODE_ID] [HASH] -o [FILE_PATH]
6+
//! $ cargo run --example discovery_local_network --features="discovery-local-network" -- connect [NODE_ID] [HASH] -o [FILE_PATH]
77
//! Run that command on another machine in the same local network, replacing [FILE_PATH] to the path on which you want to save the transferred content.
88
use std::path::PathBuf;
99

1010
use anyhow::ensure;
1111
use clap::{Parser, Subcommand};
1212
use iroh::{
13-
discovery::local_swarm_discovery::LocalSwarmDiscovery, protocol::Router, Endpoint, NodeAddr,
14-
PublicKey, RelayMode, SecretKey,
13+
discovery::mdns::MdnsDiscovery, protocol::Router, Endpoint, NodeAddr, PublicKey, RelayMode,
14+
SecretKey,
1515
};
1616
use iroh_blobs::{net_protocol::Blobs, rpc::client::blobs::WrapOption, Hash};
1717
use tracing_subscriber::{prelude::*, EnvFilter};
@@ -60,9 +60,9 @@ async fn main() -> anyhow::Result<()> {
6060
let cli = Cli::parse();
6161

6262
let key = SecretKey::generate(rand::rngs::OsRng);
63-
let discovery = LocalSwarmDiscovery::new(key.public())?;
63+
let discovery = MdnsDiscovery::new(key.public())?;
6464

65-
println!("Starting iroh node with local node discovery...");
65+
println!("Starting iroh node with mdns discovery...");
6666
// create a new node
6767
let endpoint = Endpoint::builder()
6868
.secret_key(key)
@@ -94,7 +94,7 @@ async fn main() -> anyhow::Result<()> {
9494
)
9595
.await?;
9696
let outcome = stream.finish().await?;
97-
println!("To fetch the blob:\n\tcargo run --example local_swarm_discovery --features=\"local-swarm-discovery\" -- connect {} {} -o [FILE_PATH]", node.endpoint().node_id(), outcome.hash);
97+
println!("To fetch the blob:\n\tcargo run --example discovery_local_network --features=\"discovery-local-network\" -- connect {} {} -o [FILE_PATH]", node.endpoint().node_id(), outcome.hash);
9898
tokio::signal::ctrl_c().await?;
9999
node.shutdown().await?;
100100
std::process::exit(0);

Diff for: src/net_protocol.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{
1313
use anyhow::{bail, Result};
1414
use futures_lite::future::Boxed as BoxedFuture;
1515
use futures_util::future::BoxFuture;
16-
use iroh::{endpoint::Connecting, protocol::ProtocolHandler, Endpoint, NodeAddr};
16+
use iroh::{endpoint::Connection, protocol::ProtocolHandler, Endpoint, NodeAddr};
1717
use serde::{Deserialize, Serialize};
1818
use tracing::debug;
1919

@@ -318,13 +318,13 @@ impl<S: crate::store::Store> Blobs<S> {
318318
}
319319

320320
impl<S: crate::store::Store> ProtocolHandler for Blobs<S> {
321-
fn accept(&self, conn: Connecting) -> BoxedFuture<Result<()>> {
321+
fn accept(&self, conn: Connection) -> BoxedFuture<Result<()>> {
322322
let db = self.store().clone();
323323
let events = self.events().clone();
324324
let rt = self.rt().clone();
325325

326326
Box::pin(async move {
327-
crate::provider::handle_connection(conn.await?, db, events, rt).await;
327+
crate::provider::handle_connection(conn, db, events, rt).await;
328328
Ok(())
329329
})
330330
}

0 commit comments

Comments
 (0)