diff --git a/zebra-network/src/peer/connector.rs b/zebra-network/src/peer/connector.rs index 1bf58be5f..7c1633c90 100644 --- a/zebra-network/src/peer/connector.rs +++ b/zebra-network/src/peer/connector.rs @@ -11,7 +11,7 @@ use tower::{discover::Change, Service, ServiceExt}; use crate::{BoxedStdError, Request, Response}; -use super::{Client, Handshake, HandshakeError}; +use super::{Client, Handshake}; /// A wrapper around [`peer::Handshake`] that opens a TCP connection before /// forwarding to the inner handshake service. Writing this as its own @@ -40,7 +40,7 @@ where S::Future: Send, { type Response = Change; - type Error = HandshakeError; + type Error = BoxedStdError; type Future = Pin> + Send + 'static>>; diff --git a/zebra-network/src/peer/handshake.rs b/zebra-network/src/peer/handshake.rs index c917aa3b3..4894977d8 100644 --- a/zebra-network/src/peer/handshake.rs +++ b/zebra-network/src/peer/handshake.rs @@ -80,7 +80,7 @@ where S::Future: Send, { type Response = Client; - type Error = HandshakeError; + type Error = BoxedStdError; type Future = Pin> + Send + 'static>>; @@ -257,6 +257,16 @@ where Ok(client) }; - fut.instrument(connector_span).boxed() + + // Spawn a new task to drive this handshake. + tokio::spawn(fut.instrument(connector_span)) + // This is required to get error types to line up. + // Probably there's a nicer way to express this using combinators. + .map(|x| match x { + Ok(Ok(client)) => Ok(client), + Ok(Err(handshake_err)) => Err(handshake_err.into()), + Err(join_err) => Err(join_err.into()), + }) + .boxed() } }