diff --git a/examples/n2c-miniprotocols/src/main.rs b/examples/n2c-miniprotocols/src/main.rs index 145617f..99a07e8 100644 --- a/examples/n2c-miniprotocols/src/main.rs +++ b/examples/n2c-miniprotocols/src/main.rs @@ -43,6 +43,7 @@ async fn do_chainsync(client: &mut NodeClient) { } } +#[cfg(target_family = "unix")] #[tokio::main] async fn main() { tracing::subscriber::set_global_default( @@ -66,6 +67,7 @@ async fn main() { } #[cfg(not(target_family = "unix"))] + fn main() { panic!("can't use n2c unix socket on non-unix systems"); } diff --git a/pallas-network/src/facades.rs b/pallas-network/src/facades.rs index 4623be7..1e5fd99 100644 --- a/pallas-network/src/facades.rs +++ b/pallas-network/src/facades.rs @@ -88,6 +88,8 @@ pub struct NodeClient { } impl NodeClient { + + #[cfg(not(target_os = "windows"))] pub async fn connect(path: impl AsRef, magic: u64) -> Result { debug!("connecting"); diff --git a/pallas-network/src/multiplexer.rs b/pallas-network/src/multiplexer.rs index 28f3931..ec9530f 100644 --- a/pallas-network/src/multiplexer.rs +++ b/pallas-network/src/multiplexer.rs @@ -6,12 +6,15 @@ use std::net::SocketAddr; use std::path::Path; use thiserror::Error; use tokio::io::AsyncWriteExt; -use tokio::net::{TcpListener, TcpStream, ToSocketAddrs, UnixStream}; +use tokio::net::{TcpListener, TcpStream, ToSocketAddrs}; use tokio::select; use tokio::sync::mpsc::error::SendError; use tokio::time::Instant; use tracing::{debug, error, trace}; +#[cfg(not(target_os = "windows"))] +use UnixStream; + const HEADER_LEN: usize = 8; pub type Timestamp = u32; @@ -57,6 +60,12 @@ pub struct Segment { pub payload: Payload, } +#[cfg(target_os = "windows")] +pub enum Bearer { + Tcp(TcpStream) +} + +#[cfg(not(target_os = "windows"))] pub enum Bearer { Tcp(TcpStream), Unix(UnixStream), @@ -75,6 +84,7 @@ impl Bearer { Ok((Self::Tcp(stream), addr)) } + #[cfg(not(target_os = "windows"))] pub async fn connect_unix(path: impl AsRef) -> Result { let stream = UnixStream::connect(path).await?; Ok(Self::Unix(stream)) @@ -83,6 +93,7 @@ impl Bearer { pub async fn readable(&self) -> tokio::io::Result<()> { match self { Bearer::Tcp(x) => x.readable().await, + #[cfg(not(target_os = "windows"))] Bearer::Unix(x) => x.readable().await, } } @@ -90,6 +101,7 @@ impl Bearer { fn try_read(&mut self, buf: &mut [u8]) -> tokio::io::Result { match self { Bearer::Tcp(x) => x.try_read(buf), + #[cfg(not(target_os = "windows"))] Bearer::Unix(x) => x.try_read(buf), } } @@ -97,6 +109,7 @@ impl Bearer { async fn write_all(&mut self, buf: &[u8]) -> tokio::io::Result<()> { match self { Bearer::Tcp(x) => x.write_all(buf).await, + #[cfg(not(target_os = "windows"))] Bearer::Unix(x) => x.write_all(buf).await, } } @@ -104,6 +117,7 @@ impl Bearer { async fn flush(&mut self) -> tokio::io::Result<()> { match self { Bearer::Tcp(x) => x.flush().await, + #[cfg(not(target_os = "windows"))] Bearer::Unix(x) => x.flush().await, } } diff --git a/pallas-traverse/src/aux.rs b/pallas-traverse/src/auxiliary.rs similarity index 100% rename from pallas-traverse/src/aux.rs rename to pallas-traverse/src/auxiliary.rs diff --git a/pallas-traverse/src/lib.rs b/pallas-traverse/src/lib.rs index 20c9a01..ec646a9 100644 --- a/pallas-traverse/src/lib.rs +++ b/pallas-traverse/src/lib.rs @@ -12,7 +12,7 @@ use pallas_primitives::{alonzo, babbage, byron}; mod support; pub mod assets; -pub mod aux; +pub mod auxiliary; pub mod block; pub mod cert; pub mod era;