Update networking code to libp2p 0.14 (#4383)

* Entirely update substrate-telemetry to futures 0.3

* Add a Closed error

* Update to libp2p 0.14

* More work

* More work

* More work

* More work

* Fix warnings

* Remove unwrap()

* Work on tests fixing

* Fix network tests

* Fix external network tests

* Update libp2p and restore Yamux in discovery test

* Ignore DNS if initializatio nfails

* Restore variables ordering

* Forgot browser-utils

* Fix downfall after merge

* Fix tests
This commit is contained in:
Pierre Krieger
2020-01-09 19:01:23 +01:00
committed by Gavin Wood
parent 6e572a9477
commit ca997cf1e4
29 changed files with 842 additions and 812 deletions
+8 -4
View File
@@ -71,7 +71,11 @@ pub fn build_transport(
let desktop_trans = tcp::TcpConfig::new();
let desktop_trans = websocket::WsConfig::new(desktop_trans.clone())
.or_transport(desktop_trans);
OptionalTransport::some(dns::DnsConfig::new(desktop_trans))
OptionalTransport::some(if let Ok(dns) = dns::DnsConfig::new(desktop_trans.clone()) {
dns.boxed()
} else {
desktop_trans.map_err(dns::DnsErr::Underlying).boxed()
})
} else {
OptionalTransport::none()
});
@@ -91,7 +95,7 @@ pub fn build_transport(
let transport = transport.and_then(move |stream, endpoint| {
let upgrade = core::upgrade::SelectUpgrade::new(noise_config, secio_config);
core::upgrade::apply(stream, upgrade, endpoint, upgrade::Version::V1)
.and_then(|out| match out {
.map(|out| match out? {
// We negotiated noise
EitherOutput::First((remote_id, out)) => {
let remote_key = match remote_id {
@@ -110,7 +114,7 @@ pub fn build_transport(
#[cfg(target_os = "unknown")]
let transport = transport.and_then(move |stream, endpoint| {
core::upgrade::apply(stream, secio_config, endpoint, upgrade::Version::V1)
.and_then(|(id, stream)| Ok((stream, id)))
.map_ok(|(id, stream)| ((stream, id)))
});
// Multiplexing
@@ -121,7 +125,7 @@ pub fn build_transport(
.map_outbound(move |muxer| (peer_id2, muxer));
core::upgrade::apply(stream, upgrade, endpoint, upgrade::Version::V1)
.map(|(id, muxer)| (id, core::muxing::StreamMuxerBox::new(muxer)))
.map_ok(|(id, muxer)| (id, core::muxing::StreamMuxerBox::new(muxer)))
})
.timeout(Duration::from_secs(20))