diff --git a/transports/quic/src/config.rs b/transports/quic/src/config.rs index 1c07af8207f..79cc86f2309 100644 --- a/transports/quic/src/config.rs +++ b/transports/quic/src/config.rs @@ -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)] diff --git a/transports/quic/src/connection/connecting.rs b/transports/quic/src/connection/connecting.rs index ec581baaca4..32324b766d2 100644 --- a/transports/quic/src/connection/connecting.rs +++ b/transports/quic/src/connection/connecting.rs @@ -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::{ diff --git a/transports/quic/src/lib.rs b/transports/quic/src/lib.rs index 9745b3851a2..957c5476f82 100644 --- a/transports/quic/src/lib.rs +++ b/transports/quic/src/lib.rs @@ -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")] diff --git a/transports/quic/src/transport.rs b/transports/quic/src/transport.rs index 87051396ad5..164a3048fb6 100644 --- a/transports/quic/src/transport.rs +++ b/transports/quic/src/transport.rs @@ -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; @@ -89,7 +89,11 @@ impl GenTransport

{ } } /// Create a new [`quinn::Endpoint`] with the given configs. - fn new_endpoint(endpoint_config: quinn::EndpointConfig, server_config: Option, socket_addr: SocketAddr) -> Result { + fn new_endpoint( + endpoint_config: quinn::EndpointConfig, + server_config: Option, + socket_addr: SocketAddr, + ) -> Result { let socket = UdpSocket::bind(socket_addr)?; let endpoint = quinn::Endpoint::new(endpoint_config, server_config, socket, P::runtime())?; Ok(endpoint) @@ -185,7 +189,8 @@ impl Transport for GenTransport

{ 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 @@ -211,7 +216,8 @@ impl Transport for GenTransport

{ // 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 })) @@ -349,11 +355,9 @@ impl Listener

{ 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, @@ -362,11 +366,9 @@ impl Listener

{ } } 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,