Update libp2p to 0.16 (#4928)

* Update libp2p to 0.16

* Actually update to libp2p 0.16 🤦

* Fix missed updates

* Fix peerset tests
This commit is contained in:
Pierre Krieger
2020-02-17 11:32:37 +01:00
committed by GitHub
parent c8fa6518bf
commit 13cba8dad1
23 changed files with 226 additions and 206 deletions
+8 -9
View File
@@ -23,8 +23,7 @@ use crate::protocol::{self, light_client_handler, CustomMessageOutcome, Protocol
use libp2p::NetworkBehaviour;
use libp2p::core::{Multiaddr, PeerId, PublicKey};
use libp2p::kad::record;
use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess};
use libp2p::core::{nodes::Substream, muxing::StreamMuxerBox};
use libp2p::swarm::{NetworkBehaviourAction, NetworkBehaviourEventProcess, PollParameters};
use log::debug;
use sp_consensus::{BlockOrigin, import_queue::{IncomingBlock, Origin}};
use sp_runtime::{traits::{Block as BlockT, NumberFor}, Justification};
@@ -39,13 +38,13 @@ pub struct Behaviour<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> {
substrate: Protocol<B, S, H>,
/// Periodically pings and identifies the nodes we are connected to, and store information in a
/// cache.
debug_info: debug_info::DebugInfoBehaviour<Substream<StreamMuxerBox>>,
debug_info: debug_info::DebugInfoBehaviour,
/// Discovers nodes of the network.
discovery: DiscoveryBehaviour<Substream<StreamMuxerBox>>,
discovery: DiscoveryBehaviour,
/// Block request handling.
block_requests: protocol::BlockRequests<Substream<StreamMuxerBox>, B>,
block_requests: protocol::BlockRequests<B>,
/// Light client request handling.
light_client_handler: protocol::LightClientHandler<Substream<StreamMuxerBox>, B>,
light_client_handler: protocol::LightClientHandler<B>,
/// Queue of events to produce for the outside.
#[behaviour(ignore)]
events: Vec<BehaviourOut<B>>,
@@ -69,8 +68,8 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Behaviour<B, S, H> {
enable_mdns: bool,
allow_private_ipv4: bool,
discovery_only_if_under_num: u64,
block_requests: protocol::BlockRequests<Substream<StreamMuxerBox>, B>,
light_client_handler: protocol::LightClientHandler<Substream<StreamMuxerBox>, B>,
block_requests: protocol::BlockRequests<B>,
light_client_handler: protocol::LightClientHandler<B>,
) -> Self {
Behaviour {
substrate,
@@ -223,7 +222,7 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> NetworkBehaviourEventPr
}
impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Behaviour<B, S, H> {
fn poll<TEv>(&mut self, _: &mut Context) -> Poll<NetworkBehaviourAction<TEv, BehaviourOut<B>>> {
fn poll<TEv>(&mut self, _: &mut Context, _: &mut impl PollParameters) -> Poll<NetworkBehaviourAction<TEv, BehaviourOut<B>>> {
if !self.events.is_empty() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(self.events.remove(0)))
}