Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kpp committed Feb 15, 2023
1 parent 953ce83 commit df0f789
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
5 changes: 1 addition & 4 deletions transports/quic/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
// DEALINGS IN THE SOFTWARE.

use quinn::VarInt;
use std::{
sync::Arc,
time::Duration,
};
use std::{sync::Arc, time::Duration};

/// Config for the transport.
#[derive(Clone)]
Expand Down
5 changes: 4 additions & 1 deletion transports/quic/src/connection/connecting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
use crate::{Connection, ConnectionError, Error};

use futures::{prelude::*, future::{Either, select, Select}};
use futures::{
future::{select, Either, Select},
prelude::*,
};
use futures_timer::Delay;
use libp2p_core::PeerId;
use std::{
Expand Down
4 changes: 2 additions & 2 deletions transports/quic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

mod connection;
mod config;
mod connection;
mod provider;
mod transport;

pub use connection::{Connecting, Connection, Substream};
pub use config::Config;
pub use connection::{Connecting, Connection, Substream};
#[cfg(feature = "async-std")]
pub use provider::async_std;
#[cfg(feature = "tokio")]
Expand Down
30 changes: 16 additions & 14 deletions transports/quic/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

use crate::config::{Config, QuinnConfig};
use crate::provider::Provider;
use crate::{Connecting, ConnectError, Connection, Error};
use crate::{ConnectError, Connecting, Connection, Error};

use futures::future::BoxFuture;
use futures::ready;
Expand Down Expand Up @@ -89,7 +89,11 @@ impl<P: Provider> GenTransport<P> {
}
}
/// Create a new [`quinn::Endpoint`] with the given configs.
fn new_endpoint(endpoint_config: quinn::EndpointConfig, server_config: Option<quinn::ServerConfig>, socket_addr: SocketAddr) -> Result<quinn::Endpoint, Error> {
fn new_endpoint(
endpoint_config: quinn::EndpointConfig,
server_config: Option<quinn::ServerConfig>,
socket_addr: SocketAddr,
) -> Result<quinn::Endpoint, Error> {
let socket = UdpSocket::bind(socket_addr)?;
let endpoint = quinn::Endpoint::new(endpoint_config, server_config, socket, P::runtime())?;
Ok(endpoint)
Expand Down Expand Up @@ -185,7 +189,8 @@ impl<P: Provider> Transport for GenTransport<P> {
SocketFamily::Ipv6 => SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), 0),
};
let endpoint_config = self.quinn_config.endpoint_config.clone();
let endpoint = Self::new_endpoint(endpoint_config, None, listen_socket_addr)?;
let endpoint =
Self::new_endpoint(endpoint_config, None, listen_socket_addr)?;

vacant.insert(endpoint.clone());
endpoint
Expand All @@ -211,7 +216,8 @@ impl<P: Provider> Transport for GenTransport<P> {
// This `"l"` seems necessary because an empty string is an invalid domain
// name. While we don't use domain names, the underlying rustls library
// is based upon the assumption that we do.
let connecting = endpoint.connect_with(client_config, socket_addr, "l")
let connecting = endpoint
.connect_with(client_config, socket_addr, "l")
.map_err(ConnectError)?;
Connecting::new(connecting, handshake_timeout).await
}))
Expand Down Expand Up @@ -349,11 +355,9 @@ impl<P: Provider> Listener<P> {
loop {
match ready!(P::poll_if_event(if_watcher, cx)) {
Ok(IfEvent::Up(inet)) => {
if let Some(listen_addr) = ip_to_listenaddr(
&endpoint_addr,
inet.addr(),
self.version,
) {
if let Some(listen_addr) =
ip_to_listenaddr(&endpoint_addr, inet.addr(), self.version)
{
log::debug!("New listen address: {}", listen_addr);
return Poll::Ready(TransportEvent::NewAddress {
listener_id: self.listener_id,
Expand All @@ -362,11 +366,9 @@ impl<P: Provider> Listener<P> {
}
}
Ok(IfEvent::Down(inet)) => {
if let Some(listen_addr) = ip_to_listenaddr(
&endpoint_addr,
inet.addr(),
self.version,
) {
if let Some(listen_addr) =
ip_to_listenaddr(&endpoint_addr, inet.addr(), self.version)
{
log::debug!("Expired listen address: {}", listen_addr);
return Poll::Ready(TransportEvent::AddressExpired {
listener_id: self.listener_id,
Expand Down

0 comments on commit df0f789

Please sign in to comment.