Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Reduce the number of types in build_transport for transport (#9793)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpp authored Sep 16, 2021
1 parent d67e5f4 commit 25eb7ac
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions client/network/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,16 @@ pub fn build_transport(
let desktop_trans =
websocket::WsConfig::new(desktop_trans.clone()).or_transport(desktop_trans);
let dns_init = futures::executor::block_on(dns::DnsConfig::system(desktop_trans.clone()));
OptionalTransport::some(if let Ok(dns) = dns_init {
EitherTransport::Left(if let Ok(dns) = dns_init {
EitherTransport::Left(dns)
} else {
EitherTransport::Right(desktop_trans.map_err(dns::DnsErr::Transport))
})
} else {
// For the in-memory case we set up the transport with an `.or_transport` below.
OptionalTransport::none()
EitherTransport::Right(OptionalTransport::some(
libp2p::core::transport::MemoryTransport::default(),
))
};
let transport = transport.or_transport(if memory_only {
OptionalTransport::some(libp2p::core::transport::MemoryTransport::default())
} else {
OptionalTransport::none()
});

let (transport, bandwidth) = bandwidth::BandwidthLogging::new(transport);

Expand Down

0 comments on commit 25eb7ac

Please sign in to comment.