Skip to content

Commit

Permalink
fix: support windows builds
Browse files Browse the repository at this point in the history
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] #35
[1] https://doc.rust-lang.org/reference/conditional-compilation.html#target_family
  • Loading branch information
conorsch committed Oct 13, 2023
1 parent 1e622b1 commit f1e1287
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/v034/server.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -126,6 +129,7 @@ where
ServerBuilder::default()
}

#[cfg(target_family = "unix")]
pub async fn listen_unix(self, path: impl AsRef<Path>) -> Result<(), BoxError> {
let listener = UnixListener::bind(path)?;
let addr = listener.local_addr()?;
Expand Down
10 changes: 8 additions & 2 deletions src/v037/server.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -126,6 +131,7 @@ where
ServerBuilder::default()
}

#[cfg(target_family = "unix")]
pub async fn listen_unix(self, path: impl AsRef<Path>) -> Result<(), BoxError> {
let listener = UnixListener::bind(path)?;
let addr = listener.local_addr()?;
Expand Down

0 comments on commit f1e1287

Please sign in to comment.