Skip to content

chore: update to latest iroh #77

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

Merged
merged 4 commits into from
Mar 18, 2025
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
37 changes: 24 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 7 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ genawaiter = { version = "0.99.1", features = ["futures03"] }
hashlink = { version = "0.9.0", optional = true }
hex = "0.4.3"
indicatif = { version = "0.17.8", optional = true }
iroh-base = { version = "0.33" }
iroh-base = { version = "0.34" }
iroh-io = { version = "0.6.0", features = ["stats"] }
iroh-metrics = { version = "0.31", default-features = false }
iroh = "0.33"
iroh-metrics = { version = "0.32", default-features = false }
iroh = "0.34"
nested_enum_utils = { version = "0.1.0", optional = true }
num_cpus = "1.15.0"
oneshot = "0.1.8"
Expand All @@ -54,8 +54,8 @@ postcard = { version = "1", default-features = false, features = [
"use-std",
"experimental-derive",
] }
quic-rpc = { version = "0.18.3", optional = true }
quic-rpc-derive = { version = "0.18", optional = true }
quic-rpc = { version = "0.19", optional = true }
quic-rpc-derive = { version = "0.19", optional = true }
rand = "0.8"
range-collections = "0.4.0"
redb = { version = "2.2.0", optional = true }
Expand All @@ -80,7 +80,7 @@ tracing-test = "0.2.5"

[dev-dependencies]
http-body = "1.0"
iroh = { version = "0.33", features = ["test-utils"] }
iroh = { version = "0.34", features = ["test-utils"] }
quinn = { package = "iroh-quinn", version = "0.13", features = ["ring"] }
futures-buffered = "0.2.4"
proptest = "1.0.0"
Expand Down Expand Up @@ -149,7 +149,7 @@ name = "hello-world-provide"
required-features = ["example-iroh"]

[[example]]
name = "local-swarm-discovery"
name = "discovery-local-network"
required-features = ["example-iroh"]

[[example]]
Expand Down Expand Up @@ -184,8 +184,3 @@ debug-assertions = false
opt-level = 3
panic = 'abort'
incremental = false

[patch.crates-io]
iroh = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
iroh-base = { git = "https://github.com/n0-computer/iroh.git", branch = "main" }
quic-rpc = { git = "https://github.com/n0-computer/quic-rpc", branch = "main" }
6 changes: 1 addition & 5 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ ignore = [
"RUSTSEC-2024-0370", # unmaintained, no upgrade available
"RUSTSEC-2024-0384", # unmaintained, no upgrade available
"RUSTSEC-2024-0436", # unmaintained paste
"RUSTSEC-2025-0012", # unmaintained backoff
]

[sources]
allow-git = [
"https://github.com/n0-computer/iroh.git",
"https://github.com/n0-computer/quic-rpc.git"
]
allow-git = []
6 changes: 2 additions & 4 deletions examples/custom-protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use anyhow::Result;
use clap::Parser;
use futures_lite::future::Boxed as BoxedFuture;
use iroh::{
endpoint::Connecting,
endpoint::Connection,
protocol::{ProtocolHandler, Router},
Endpoint, NodeId,
};
Expand Down Expand Up @@ -142,12 +142,10 @@ impl ProtocolHandler for BlobSearch {
///
/// The returned future runs on a newly spawned tokio task, so it can run as long as
/// the connection lasts.
fn accept(&self, connecting: Connecting) -> BoxedFuture<Result<()>> {
fn accept(&self, connection: Connection) -> BoxedFuture<Result<()>> {
let this = self.clone();
// We have to return a boxed future from the handler.
Box::pin(async move {
// Wait for the connection to be fully established.
let connection = connecting.await?;
// We can get the remote's node id from the connection.
let node_id = connection.remote_node_id()?;
println!("accepted connection from {node_id}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//! Example that runs and iroh node with local node discovery and no relay server
//!
//! Run the follow command to run the "accept" side, that hosts the content:
//! $ cargo run --example local_swarm_discovery --features="discovery-local-network" -- accept [FILE_PATH]
//! $ cargo run --example discovery_local_network --features="discovery-local-network" -- accept [FILE_PATH]
//! Wait for output that looks like the following:
//! $ cargo run --example local_swarm_discovery --features="discovery-local-network" -- connect [NODE_ID] [HASH] -o [FILE_PATH]
//! $ cargo run --example discovery_local_network --features="discovery-local-network" -- connect [NODE_ID] [HASH] -o [FILE_PATH]
//! 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.
use std::path::PathBuf;

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

let key = SecretKey::generate(rand::rngs::OsRng);
let discovery = LocalSwarmDiscovery::new(key.public())?;
let discovery = MdnsDiscovery::new(key.public())?;

println!("Starting iroh node with local node discovery...");
println!("Starting iroh node with mdns discovery...");
// create a new node
let endpoint = Endpoint::builder()
.secret_key(key)
Expand Down Expand Up @@ -94,7 +94,7 @@ async fn main() -> anyhow::Result<()> {
)
.await?;
let outcome = stream.finish().await?;
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);
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);
tokio::signal::ctrl_c().await?;
node.shutdown().await?;
std::process::exit(0);
Expand Down
6 changes: 3 additions & 3 deletions src/net_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
use anyhow::{bail, Result};
use futures_lite::future::Boxed as BoxedFuture;
use futures_util::future::BoxFuture;
use iroh::{endpoint::Connecting, protocol::ProtocolHandler, Endpoint, NodeAddr};
use iroh::{endpoint::Connection, protocol::ProtocolHandler, Endpoint, NodeAddr};
use serde::{Deserialize, Serialize};
use tracing::debug;

Expand Down Expand Up @@ -318,13 +318,13 @@ impl<S: crate::store::Store> Blobs<S> {
}

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

Box::pin(async move {
crate::provider::handle_connection(conn.await?, db, events, rt).await;
crate::provider::handle_connection(conn, db, events, rt).await;
Ok(())
})
}
Expand Down
Loading