Skip to content

Commit

Permalink
chore: fix doc and remove no longer needed explicit shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian1409 committed Nov 25, 2024
1 parent b29ec3a commit b91f2cd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 24 deletions.
7 changes: 0 additions & 7 deletions mpc-net/examples/three_party.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use mpc_net::{
config::{NetworkConfig, NetworkConfigFile},
MpcNetworkHandler,
};
use tokio::io::AsyncWriteExt;

#[derive(Parser)]
struct Args {
Expand Down Expand Up @@ -50,12 +49,6 @@ async fn main() -> Result<()> {
}
}

// make sure all write are done by shutting down all streams
for (_, channel) in channels.into_iter() {
let (write, _) = channel.split();
write.into_inner().shutdown().await?;
}

network.print_connection_stats(&mut std::io::stdout())?;

Ok(())
Expand Down
7 changes: 1 addition & 6 deletions mpc-net/examples/three_party_bincode_channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use mpc_net::{
MpcNetworkHandler,
};
use serde::{Deserialize, Serialize};
use tokio::io::AsyncWriteExt;

#[derive(Parser)]
struct Args {
Expand Down Expand Up @@ -67,11 +66,7 @@ async fn main() -> Result<()> {
panic!("could not receive message");
}
}
// make sure all write are done by shutting down all streams
for (_, channel) in channels.into_iter() {
let (write, _) = channel.split();
write.into_inner().shutdown().await?;
}

network.print_connection_stats(&mut std::io::stdout())?;

Ok(())
Expand Down
7 changes: 1 addition & 6 deletions mpc-net/examples/three_party_custom_channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use mpc_net::{
config::{NetworkConfig, NetworkConfigFile},
MpcNetworkHandler,
};
use tokio::io::AsyncWriteExt;
use tokio_util::codec::{Decoder, Encoder};

#[derive(Parser)]
Expand Down Expand Up @@ -67,11 +66,7 @@ async fn main() -> Result<()> {
panic!("could not receive message");
}
}
// make sure all write are done by shutting down all streams
for (_, channel) in channels.into_iter() {
let (write, _) = channel.split();
write.into_inner().shutdown().await?;
}

network.print_connection_stats(&mut std::io::stdout())?;

Ok(())
Expand Down
5 changes: 1 addition & 4 deletions mpc-net/examples/three_party_managed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ async fn main() -> Result<()> {
assert!(b.iter().all(|&x| x == my_id as u8))
}
}
// drop handles so we can shutdown
drop(managed_channels);
// wait until all send and recv taks are done
network.shutdown().await?;

network.print_connection_stats(&mut std::io::stdout())?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion mpc-net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub mod config;
// TODO get this from network config
const STREAMS_PER_CONN: usize = 8;

/// Type alias for a [rustls::TcpStream] over a [TcpStream].
/// Type alias for a [tokio_rustls::TlsStream] over a [TcpStream].
type TlsStream = tokio_rustls::TlsStream<TcpStream>;

/// A duplex TLS stream that uses one stream for sending and one for receiving.
Expand Down

0 comments on commit b91f2cd

Please sign in to comment.