diff --git a/Cargo.lock b/Cargo.lock index ee611751d2..72fba41a2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2986,7 +2986,7 @@ dependencies = [ [[package]] name = "iroh-willow" -version = "0.24.0" +version = "0.27.0" dependencies = [ "anyhow", "bytes", diff --git a/iroh-willow/Cargo.toml b/iroh-willow/Cargo.toml index 5fdabf0780..eaede55d8d 100644 --- a/iroh-willow/Cargo.toml +++ b/iroh-willow/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iroh-willow" -version = "0.24.0" +version = "0.27.0" edition = "2021" readme = "README.md" description = "willow protocol implementation for iroh" @@ -18,7 +18,7 @@ workspace = true anyhow = "1" bytes = { version = "1.4", features = ["serde"] } curve25519-dalek = { version = "4.1.3", features = [ "digest", "rand_core", "serde", ] } -derive_more = { version = "=1.0.0-beta.7", features = [ "debug", "deref", "display", "from", "try_into", "into", "as_ref", "try_from", ] } +derive_more = { version = "1.0.0", features = [ "debug", "deref", "display", "from", "try_into", "into", "as_ref", "try_from", ] } ed25519-dalek = { version = "2.0.0", features = ["serde", "rand_core"] } either = "1.13.0" futures-buffered = "0.2.6" @@ -27,12 +27,12 @@ futures-lite = "2.3.0" futures-util = "0.3.30" genawaiter = "0.99.1" hex = "0.4.3" -iroh-base = { version = "0.24.0", path = "../iroh-base" } +iroh-base = { version = "0.27.0", path = "../iroh-base" } iroh-blake3 = "1.4.5" -iroh-blobs = { version = "0.24.0", path = "../iroh-blobs" } +iroh-blobs = { version = "0.27.0", path = "../iroh-blobs" } iroh-io = { version = "0.6.0", features = ["stats"] } -iroh-metrics = { version = "0.24.0", path = "../iroh-metrics", optional = true } -iroh-net = { version = "0.24.0", path = "../iroh-net" } +iroh-metrics = { version = "0.27.0", path = "../iroh-metrics", optional = true } +iroh-net = { version = "0.27.0", path = "../iroh-net" } meadowcap = "0.1.0" postcard = { version = "1", default-features = false, features = [ "alloc", "use-std", "experimental-derive", ] } rand = "0.8.5" diff --git a/iroh-willow/src/engine.rs b/iroh-willow/src/engine.rs index 4f506620bc..816f95546c 100644 --- a/iroh-willow/src/engine.rs +++ b/iroh-willow/src/engine.rs @@ -123,14 +123,14 @@ impl Engine { /// /// This will try to close all connections gracefully for up to 10 seconds, /// and abort them otherwise. - pub async fn shutdown(mut self) -> Result<()> { + pub async fn shutdown(&self) -> Result<()> { debug!("shutdown engine"); let (reply, reply_rx) = oneshot::channel(); self.peer_manager_inbox .send(peer_manager::Input::Shutdown { reply }) .await?; reply_rx.await?; - let res = (&mut self.peer_manager_task).await; + let res = self.peer_manager_task.clone().await; match res { Err(err) => error!(?err, "peer manager task panicked"), Ok(Err(err)) => error!(?err, "peer manager task failed"), diff --git a/iroh-willow/src/engine/peer_manager.rs b/iroh-willow/src/engine/peer_manager.rs index 8b43bd45cd..50cac9860a 100644 --- a/iroh-willow/src/engine/peer_manager.rs +++ b/iroh-willow/src/engine/peer_manager.rs @@ -304,7 +304,7 @@ impl PeerManager { let fut = async move { debug!("connecting"); let conn = tokio::select! { - res = endpoint.connect_by_node_id(peer, ALPN) => res, + res = endpoint.connect(peer, ALPN) => res, _ = cancel_dial.cancelled() => { debug!("dial cancelled during dial"); return Err(ConnectionError::LocallyClosed.into()); diff --git a/iroh/src/node.rs b/iroh/src/node.rs index 1125336d35..1f1b233b3f 100644 --- a/iroh/src/node.rs +++ b/iroh/src/node.rs @@ -464,30 +464,6 @@ impl NodeInner { async fn shutdown(&self, protocols: Arc) { let error_code = Closed::ProviderTerminating; - // Shutdown future for the docs engine, if enabled. - let docs_shutdown = { - let docs = self.docs.clone(); - async move { - if let Some(docs) = docs { - docs.shutdown().await - } else { - Ok(()) - } - } - }; - - // Shutdown willow gracefully. - let spaces_shutdown = { - let engine = self.willow.clone(); - async move { - if let Some(engine) = engine { - if let Err(error) = engine.shutdown().await { - warn!(?error, "Error while shutting down willow"); - } - } - } - }; - // We ignore all errors during shutdown. let _ = tokio::join!( // Close the endpoint. @@ -497,12 +473,6 @@ impl NodeInner { self.endpoint .clone() .close(error_code.into(), error_code.reason()), - // Shutdown docs engine. - docs_shutdown, - // Shutdown spaces engine. - spaces_shutdown, - // Shutdown blobs store engine. - self.db.shutdown(), // Shutdown protocol handlers. protocols.shutdown(), ); diff --git a/iroh/src/node/builder.rs b/iroh/src/node/builder.rs index fa110fc278..0daa3a02ee 100644 --- a/iroh/src/node/builder.rs +++ b/iroh/src/node/builder.rs @@ -918,7 +918,7 @@ impl ProtocolBuilder { } if let Some(engine) = self.inner.willow.clone() { - self = self.accept(iroh_willow::ALPN, Arc::new(engine)); + self = self.accept(iroh_willow::ALPN.to_vec(), Arc::new(engine)); } self diff --git a/iroh/src/node/protocol.rs b/iroh/src/node/protocol.rs index d4ca2e62b7..c6a17b5c35 100644 --- a/iroh/src/node/protocol.rs +++ b/iroh/src/node/protocol.rs @@ -348,4 +348,12 @@ impl ProtocolHandler for iroh_willow::Engine { fn accept(self: Arc, conn: Connecting) -> BoxedFuture> { Box::pin(async move { self.handle_connection(conn.await?).await }) } + + fn shutdown(self: Arc) -> BoxedFuture<()> { + Box::pin(async move { + if let Err(e) = (&**self).shutdown().await { + tracing::error!(?e, "Error while shutting down willow engine"); + } + }) + } }