Skip to content

Commit

Permalink
fix: unneeded async
Browse files Browse the repository at this point in the history
  • Loading branch information
b-zee authored and joshuef committed Jan 20, 2023
1 parent aa6197b commit 0538e57
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions examples/p2p_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ async fn main() -> Result<()> {
let (node, mut incoming_conns) = Endpoint::builder()
.addr((Ipv4Addr::LOCALHOST, 0))
.idle_timeout(60 * 60 * 1_000 /* 3600s = 1h */)
.server()
.await?;
.server()?;

// if we received args then we parse them as SocketAddr and send a "marco" msg to each peer.
if args.len() > 1 {
Expand Down
4 changes: 2 additions & 2 deletions src/endpoint_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl EndpointBuilder {
}

/// Instantiate a server (peer) [`Endpoint`] using the parameters passed to this builder.
pub async fn server(self) -> Result<(Endpoint, IncomingConnections), EndpointError> {
pub fn server(self) -> Result<(Endpoint, IncomingConnections), EndpointError> {
let (cfg_srv, cfg_cli) = self.config()?;

let mut endpoint = quinn::Endpoint::server(cfg_srv, self.addr)?;
Expand All @@ -95,7 +95,7 @@ impl EndpointBuilder {
}

/// Instantiate a client (unreachable) [`Endpoint`] using the parameters passed to this builder.
pub async fn client(self) -> Result<Endpoint, EndpointError> {
pub fn client(self) -> Result<Endpoint, EndpointError> {
let (_, cfg_cli) = self.config()?;

let mut endpoint = quinn::Endpoint::client(self.addr)?;
Expand Down
7 changes: 3 additions & 4 deletions src/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ async fn client() -> Result<()> {
use crate::Endpoint;

let (server, mut server_connections) = new_endpoint_with_keepalive().await?;
let client = Endpoint::builder().addr(local_addr()).client().await?;
let client = Endpoint::builder().addr(local_addr()).client()?;

let (client_to_server, mut client_messages) = client.connect_to(&server.local_addr()).await?;
client_to_server
Expand Down Expand Up @@ -757,7 +757,7 @@ async fn no_client_keep_alive_times_out() -> Result<()> {
use crate::Endpoint;

let (server, mut server_connections) = new_endpoint().await?;
let client = Endpoint::builder().addr(local_addr()).client().await?;
let client = Endpoint::builder().addr(local_addr()).client()?;

let (client_to_server, _client_messages) = client.connect_to(&server.local_addr()).await?;
client_to_server
Expand Down Expand Up @@ -801,8 +801,7 @@ async fn client_keep_alive_works() -> Result<()> {
let client = Endpoint::builder()
.addr(local_addr())
.keep_alive_interval(Duration::from_secs(5))
.client()
.await?;
.client()?;

let (client_to_server, mut client_messages) = client.connect_to(&server.local_addr()).await?;
client_to_server
Expand Down
5 changes: 2 additions & 3 deletions src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ pub(crate) async fn new_endpoint_with_keepalive() -> Result<(Endpoint, IncomingC
let ep = Endpoint::builder()
.addr(local_addr())
.keep_alive_interval(Duration::from_secs(5))
.server()
.await?;
.server()?;
Ok(ep)
}
/// Construct an `Endpoint` with sane defaults for testing.
pub(crate) async fn new_endpoint() -> Result<(Endpoint, IncomingConnections)> {
let ep = Endpoint::builder().addr(local_addr()).server().await?;
let ep = Endpoint::builder().addr(local_addr()).server()?;
Ok(ep)
}

Expand Down

0 comments on commit 0538e57

Please sign in to comment.