mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 12:41:07 +00:00
*: Update to libp2p v0.30.0 (#7508)
* *: Update to libp2p v0.30.0 * Cargo.lock: Update * *: Update to libp2p v0.30.1
This commit is contained in:
@@ -51,11 +51,11 @@ use futures::prelude::*;
|
||||
use futures_timer::Delay;
|
||||
use ip_network::IpNetwork;
|
||||
use libp2p::core::{connection::{ConnectionId, ListenerId}, ConnectedPoint, Multiaddr, PeerId, PublicKey};
|
||||
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters, ProtocolsHandler};
|
||||
use libp2p::swarm::protocols_handler::multi::MultiHandler;
|
||||
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters, ProtocolsHandler, IntoProtocolsHandler};
|
||||
use libp2p::swarm::protocols_handler::multi::IntoMultiHandler;
|
||||
use libp2p::kad::{Kademlia, KademliaBucketInserts, KademliaConfig, KademliaEvent, QueryResult, Quorum, Record};
|
||||
use libp2p::kad::GetClosestPeersError;
|
||||
use libp2p::kad::handler::KademliaHandler;
|
||||
use libp2p::kad::handler::KademliaHandlerProto;
|
||||
use libp2p::kad::QueryId;
|
||||
use libp2p::kad::record::{self, store::{MemoryStore, RecordStore}};
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
@@ -444,14 +444,14 @@ pub enum DiscoveryOut {
|
||||
}
|
||||
|
||||
impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
type ProtocolsHandler = MultiHandler<ProtocolId, KademliaHandler<QueryId>>;
|
||||
type ProtocolsHandler = IntoMultiHandler<ProtocolId, KademliaHandlerProto<QueryId>>;
|
||||
type OutEvent = DiscoveryOut;
|
||||
|
||||
fn new_handler(&mut self) -> Self::ProtocolsHandler {
|
||||
let iter = self.kademlias.iter_mut()
|
||||
.map(|(p, k)| (p.clone(), NetworkBehaviour::new_handler(k)));
|
||||
|
||||
MultiHandler::try_from_iter(iter)
|
||||
IntoMultiHandler::try_from_iter(iter)
|
||||
.expect("There can be at most one handler per `ProtocolId` and \
|
||||
protocol names contain the `ProtocolId` so no two protocol \
|
||||
names in `self.kademlias` can be equal which is the only error \
|
||||
@@ -534,7 +534,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
&mut self,
|
||||
peer_id: PeerId,
|
||||
connection: ConnectionId,
|
||||
(pid, event): <Self::ProtocolsHandler as ProtocolsHandler>::OutEvent,
|
||||
(pid, event): <<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent,
|
||||
) {
|
||||
if let Some(kad) = self.kademlias.get_mut(&pid) {
|
||||
return kad.inject_event(peer_id, connection, event)
|
||||
@@ -598,7 +598,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<Self::ProtocolsHandler as ProtocolsHandler>::InEvent,
|
||||
<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent,
|
||||
>,
|
||||
> {
|
||||
@@ -816,7 +816,7 @@ mod tests {
|
||||
let transport = MemoryTransport
|
||||
.upgrade(upgrade::Version::V1)
|
||||
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(yamux::Config::default())
|
||||
.multiplex(yamux::YamuxConfig::default())
|
||||
.boxed();
|
||||
|
||||
let behaviour = {
|
||||
|
||||
@@ -1355,7 +1355,7 @@ mod tests {
|
||||
let transport = MemoryTransport::default()
|
||||
.upgrade(upgrade::Version::V1)
|
||||
.authenticate(NoiseConfig::xx(dh_key).into_authenticated())
|
||||
.multiplex(yamux::Config::default())
|
||||
.multiplex(yamux::YamuxConfig::default())
|
||||
.boxed();
|
||||
Swarm::new(transport, LightClientHandler::new(cf, client, checker, ps), local_peer)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ fn build_nodes() -> (Swarm<CustomProtoWithAddr>, Swarm<CustomProtoWithAddr>) {
|
||||
let transport = MemoryTransport
|
||||
.upgrade(upgrade::Version::V1)
|
||||
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(yamux::Config::default())
|
||||
.multiplex(yamux::YamuxConfig::default())
|
||||
.timeout(Duration::from_secs(20))
|
||||
.boxed();
|
||||
|
||||
|
||||
@@ -680,7 +680,7 @@ mod tests {
|
||||
let transport = MemoryTransport
|
||||
.upgrade(upgrade::Version::V1)
|
||||
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(libp2p::yamux::Config::default())
|
||||
.multiplex(libp2p::yamux::YamuxConfig::default())
|
||||
.boxed();
|
||||
|
||||
let behaviour = {
|
||||
@@ -783,7 +783,7 @@ mod tests {
|
||||
let transport = MemoryTransport
|
||||
.upgrade(upgrade::Version::V1)
|
||||
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(libp2p::yamux::Config::default())
|
||||
.multiplex(libp2p::yamux::YamuxConfig::default())
|
||||
.boxed();
|
||||
|
||||
let behaviour = {
|
||||
|
||||
@@ -104,13 +104,13 @@ pub fn build_transport(
|
||||
|
||||
let multiplexing_config = {
|
||||
let mut mplex_config = mplex::MplexConfig::new();
|
||||
mplex_config.max_buffer_len_behaviour(mplex::MaxBufferBehaviour::Block);
|
||||
mplex_config.max_buffer_len(usize::MAX);
|
||||
mplex_config.set_max_buffer_behaviour(mplex::MaxBufferBehaviour::Block);
|
||||
mplex_config.set_max_buffer_size(usize::MAX);
|
||||
|
||||
let mut yamux_config = libp2p::yamux::Config::default();
|
||||
let mut yamux_config = libp2p::yamux::YamuxConfig::default();
|
||||
// Enable proper flow-control: window updates are only sent when
|
||||
// buffered data has been consumed.
|
||||
yamux_config.set_window_update_mode(libp2p::yamux::WindowUpdateMode::OnRead);
|
||||
yamux_config.set_window_update_mode(libp2p::yamux::WindowUpdateMode::on_read());
|
||||
|
||||
core::upgrade::SelectUpgrade::new(yamux_config, mplex_config)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user