Update to libp2p v0.4 (#1836)

This commit is contained in:
Pierre Krieger
2019-02-21 10:04:53 +01:00
committed by Gav Wood
parent 19ac5e1e95
commit 2b71b3e84b
8 changed files with 159 additions and 210 deletions
+3 -3
View File
@@ -16,7 +16,7 @@
use futures::{future, stream, prelude::*, try_ready};
use std::{io, iter};
use substrate_network_libp2p::{CustomMessage, ServiceEvent, multiaddr};
use substrate_network_libp2p::{CustomMessage, Protocol, ServiceEvent, build_multiaddr};
/// Builds two services. The second one and further have the first one as its bootstrap node.
/// This is to be used only for testing, and a panic will happen if something goes wrong.
@@ -29,12 +29,12 @@ fn build_nodes<TMsg>(num: usize) -> Vec<substrate_network_libp2p::Service<TMsg>>
let mut boot_nodes = Vec::new();
if !result.is_empty() {
let mut bootnode = result[0].listeners().next().unwrap().clone();
bootnode.append(libp2p::multiaddr::Protocol::P2p(result[0].peer_id().clone().into()));
bootnode.append(Protocol::P2p(result[0].peer_id().clone().into()));
boot_nodes.push(bootnode.to_string());
}
let config = substrate_network_libp2p::NetworkConfiguration {
listen_addresses: vec![multiaddr![Ip4([127, 0, 0, 1]), Tcp(0u16)]],
listen_addresses: vec![build_multiaddr![Ip4([127, 0, 0, 1]), Tcp(0u16)]],
boot_nodes,
..substrate_network_libp2p::NetworkConfiguration::default()
};