Skip to content

Commit

Permalink
add connect windows
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega committed Dec 20, 2023
1 parent 1381491 commit 68ea22e
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion pallas-network/src/facades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl NodeClient {
}

#[cfg(unix)]
pub async fn connect(
pub async fn connect2(
path: impl AsRef<Path> + Send + 'static,
magic: u64,
) -> Result<Self, Error> {
Expand All @@ -254,6 +254,34 @@ impl NodeClient {
Ok(client)
}

#[cfg(windows)]
pub async fn connect(
pipe_name: impl AsRef<std::ffi::OsStr>,
magic: u64,
) -> Result<Self, Error> {
let bearer = tokio::task::spawn_blocking(move || Bearer::connect_named_pipe(pipe_name))

Check failure on line 262 in pallas-network/src/facades.rs

View workflow job for this annotation

GitHub Actions / Check (windows-latest, stable)

`impl AsRef<std::ffi::OsStr>` cannot be sent between threads safely
.await
.expect("can't join tokio thread")
.map_err(Error::ConnectFailure)?;

let mut client = Self::new(bearer);

let versions = handshake::n2c::VersionTable::v10_and_above(magic);

let handshake = client
.handshake()
.handshake(versions)
.await
.map_err(Error::HandshakeProtocol)?;

if let handshake::Confirmation::Rejected(reason) = handshake {
error!(?reason, "handshake refused");
return Err(Error::IncompatibleVersion);
}

Ok(client)
}

#[cfg(unix)]
pub async fn handshake_query(
bearer: Bearer,
Expand Down

0 comments on commit 68ea22e

Please sign in to comment.