From 95f2463188efc36444677a9852cf0761d8ea7063 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Thu, 17 Sep 2020 11:06:42 -0700 Subject: [PATCH] Try workaround for generator autotrait bug > Added a test that the handshake's version message matches specified fields, but the test does not compile, because rustc doesn't believe that the Box is 'static, and therefore isn't a Box. This manifests as being unable to spawn the connect_isolated task. From digging through Tokio issues I believe that this is an instance of rust-lang/rust#64552 . Co-authored-by: Jane Lusby --- zebra-network/src/isolated.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/zebra-network/src/isolated.rs b/zebra-network/src/isolated.rs index 57149a0b..223d9b9a 100644 --- a/zebra-network/src/isolated.rs +++ b/zebra-network/src/isolated.rs @@ -35,14 +35,19 @@ use crate::{peer, BoxedStdError, Config, Request, Response}; /// connection allows this method to be used with clearnet or Tor transports. /// /// - `user_agent`: a valid BIP14 user-agent, e.g., the empty string. -pub async fn connect_isolated( +pub fn connect_isolated( conn: TcpStream, user_agent: String, -) -> Result, BoxedStdError> { +) -> impl Future< + Output = Result< + BoxService>, + Box, + >, +> { let handshake = peer::Handshake::builder() .with_config(Config::default()) .with_inbound_service(tower::service_fn(|_req| async move { - Ok::(Response::Nil) + Ok::>(Response::Nil) })) .with_user_agent(user_agent) .finish() @@ -54,9 +59,7 @@ pub async fn connect_isolated( // touch it at all. let remote_addr = "0.0.0.0:8233".parse().unwrap(); - let client = Oneshot::new(handshake, (conn, remote_addr)).await?; - - Ok(BoxService::new(Wrapper(client))) + Oneshot::new(handshake, (conn, remote_addr)).map_ok(|client| BoxService::new(Wrapper(client))) } // This can be deleted when a new version of Tower with map_err is released.