From f1e12878054bcd7a86241a6c130b602691cba33a Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Fri, 13 Oct 2023 15:01:56 -0700 Subject: [PATCH] fix: support windows builds Follow up to the addition of unix socket support [0], making that feature conditional on building for a target OS family of "unix" [1]. [0] https://github.com/penumbra-zone/tower-abci/pull/35 [1] https://doc.rust-lang.org/reference/conditional-compilation.html#target_family --- src/v034/server.rs | 14 +++++++++----- src/v037/server.rs | 10 ++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/v034/server.rs b/src/v034/server.rs index 539df2c..8119624 100644 --- a/src/v034/server.rs +++ b/src/v034/server.rs @@ -1,24 +1,27 @@ use std::convert::{TryFrom, TryInto}; -use std::path::Path; use futures::future::{FutureExt, TryFutureExt}; use futures::sink::SinkExt; use futures::stream::{FuturesOrdered, StreamExt}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::{ - net::{TcpListener, ToSocketAddrs, UnixListener}, + net::{TcpListener, ToSocketAddrs}, select, }; -use tokio_util::codec::{FramedRead, FramedWrite}; -use tower::{Service, ServiceExt}; use crate::BoxError; use tendermint::abci::MethodKind; - use tendermint::v0_34::abci::{ ConsensusRequest, ConsensusResponse, InfoRequest, InfoResponse, MempoolRequest, MempoolResponse, Request, Response, SnapshotRequest, SnapshotResponse, }; +use tokio_util::codec::{FramedRead, FramedWrite}; +use tower::{Service, ServiceExt}; + +#[cfg(target_family = "unix")] +use std::path::Path; +#[cfg(target_family = "unix")] +use tokio::net::UnixListener; /// An ABCI server which listens for connections and forwards requests to four /// component ABCI [`Service`]s. @@ -126,6 +129,7 @@ where ServerBuilder::default() } + #[cfg(target_family = "unix")] pub async fn listen_unix(self, path: impl AsRef) -> Result<(), BoxError> { let listener = UnixListener::bind(path)?; let addr = listener.local_addr()?; diff --git a/src/v037/server.rs b/src/v037/server.rs index 5388e8c..3e46c06 100644 --- a/src/v037/server.rs +++ b/src/v037/server.rs @@ -1,20 +1,25 @@ use std::convert::{TryFrom, TryInto}; -use std::path::Path; use futures::future::{FutureExt, TryFutureExt}; use futures::sink::SinkExt; use futures::stream::{FuturesOrdered, StreamExt}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::{ - net::{TcpListener, ToSocketAddrs, UnixListener}, + net::{TcpListener, ToSocketAddrs}, select, }; + use tokio_util::codec::{FramedRead, FramedWrite}; use tower::{Service, ServiceExt}; use crate::BoxError; use tendermint::abci::MethodKind; +#[cfg(target_family = "unix")] +use std::path::Path; +#[cfg(target_family = "unix")] +use tokio::net::UnixListener; + use tendermint::v0_37::abci::{ ConsensusRequest, ConsensusResponse, InfoRequest, InfoResponse, MempoolRequest, MempoolResponse, Request, Response, SnapshotRequest, SnapshotResponse, @@ -126,6 +131,7 @@ where ServerBuilder::default() } + #[cfg(target_family = "unix")] pub async fn listen_unix(self, path: impl AsRef) -> Result<(), BoxError> { let listener = UnixListener::bind(path)?; let addr = listener.local_addr()?;