Reduce the number of types in build_transport for transport (#9793)

This commit is contained in:
Roman
2021-09-16 17:31:44 +03:00
committed by GitHub
parent c794c9f3a5
commit ce6e578d14
+4 -8
View File
@@ -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);