mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
Bump libp2p to 0.40.0 (#10035)
* Bump libp2p to 0.40.0-rc.1 * Fix PingFailure import * Reduce the number of compilation errors (this is a FIXME commit) * Bump libp2p to 0.40.0-rc.2 * Fix sc-network::Behaviour to inject events into fields * Fix some NetworkBehaviourAction types * More fixes * More fixes * More fixes * Fix DiscoveryBehaviour * Fix PeerInfoBehaviour * Fix RequestResponsesBehaviour * Fix RequestResponsesBehaviour * Fix Notifications * Fix NetworkWorker * Fix Behaviour * Please borrowchk * Please borrowchk * Please borrowchk * Fix fmt * Cover all cases in matches * Fix some clippy warnings * Fix into_peer_id -> to_peer_id * Fix some warnings * Fix some inject_dial_failure FIXMEs * Fix DiscoveryBehaviour::inject_dial_failure * Fix RequestResponsesBehaviour::inject_dial_failure * Fix the order of inject_connection_closed PeerInfoBehaviour events * Make KademliaEvent with filtering unreachable * Fix Notifications::inject_dial_failure * Use concurrent_dial_errors in NetworkWorker * Remove commented-out RequestResponsesBehaviour::inject_addr_reach_failure * Fix tests * Dont report new PendingConnectionError and DialError variants to metrics * Bump libp2p to 0.40.0 * Add fn inject_listen_failure and inject_address_change * Review fixes
This commit is contained in:
@@ -29,7 +29,7 @@ use libp2p::{
|
||||
},
|
||||
identity, noise,
|
||||
swarm::{
|
||||
IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, PollParameters,
|
||||
DialError, IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, PollParameters,
|
||||
ProtocolsHandler, Swarm, SwarmEvent,
|
||||
},
|
||||
yamux, Multiaddr, PeerId, Transport,
|
||||
@@ -68,7 +68,7 @@ fn build_nodes() -> (Swarm<CustomProtoWithAddr>, Swarm<CustomProtoWithAddr>) {
|
||||
in_peers: 25,
|
||||
out_peers: 25,
|
||||
bootnodes: if index == 0 {
|
||||
keypairs.iter().skip(1).map(|keypair| keypair.public().into_peer_id()).collect()
|
||||
keypairs.iter().skip(1).map(|keypair| keypair.public().to_peer_id()).collect()
|
||||
} else {
|
||||
vec![]
|
||||
},
|
||||
@@ -92,7 +92,7 @@ fn build_nodes() -> (Swarm<CustomProtoWithAddr>, Swarm<CustomProtoWithAddr>) {
|
||||
.enumerate()
|
||||
.filter_map(|(n, a)| {
|
||||
if n != index {
|
||||
Some((keypairs[n].public().into_peer_id(), a.clone()))
|
||||
Some((keypairs[n].public().to_peer_id(), a.clone()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -100,7 +100,7 @@ fn build_nodes() -> (Swarm<CustomProtoWithAddr>, Swarm<CustomProtoWithAddr>) {
|
||||
.collect(),
|
||||
};
|
||||
|
||||
let mut swarm = Swarm::new(transport, behaviour, keypairs[index].public().into_peer_id());
|
||||
let mut swarm = Swarm::new(transport, behaviour, keypairs[index].public().to_peer_id());
|
||||
swarm.listen_on(addrs[index].clone()).unwrap();
|
||||
out.push(swarm);
|
||||
}
|
||||
@@ -163,8 +163,10 @@ impl NetworkBehaviour for CustomProtoWithAddr {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
failed_addresses: Option<&Vec<Multiaddr>>,
|
||||
) {
|
||||
self.inner.inject_connection_established(peer_id, conn, endpoint)
|
||||
self.inner
|
||||
.inject_connection_established(peer_id, conn, endpoint, failed_addresses)
|
||||
}
|
||||
|
||||
fn inject_connection_closed(
|
||||
@@ -172,8 +174,9 @@ impl NetworkBehaviour for CustomProtoWithAddr {
|
||||
peer_id: &PeerId,
|
||||
conn: &ConnectionId,
|
||||
endpoint: &ConnectedPoint,
|
||||
handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
) {
|
||||
self.inner.inject_connection_closed(peer_id, conn, endpoint)
|
||||
self.inner.inject_connection_closed(peer_id, conn, endpoint, handler)
|
||||
}
|
||||
|
||||
fn inject_event(
|
||||
@@ -188,27 +191,18 @@ impl NetworkBehaviour for CustomProtoWithAddr {
|
||||
fn poll(
|
||||
&mut self,
|
||||
cx: &mut Context,
|
||||
params: &mut impl PollParameters
|
||||
) -> Poll<
|
||||
NetworkBehaviourAction<
|
||||
<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent,
|
||||
Self::OutEvent
|
||||
>
|
||||
>{
|
||||
params: &mut impl PollParameters,
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
self.inner.poll(cx, params)
|
||||
}
|
||||
|
||||
fn inject_addr_reach_failure(
|
||||
fn inject_dial_failure(
|
||||
&mut self,
|
||||
peer_id: Option<&PeerId>,
|
||||
addr: &Multiaddr,
|
||||
error: &dyn std::error::Error,
|
||||
peer_id: Option<PeerId>,
|
||||
handler: Self::ProtocolsHandler,
|
||||
error: &DialError,
|
||||
) {
|
||||
self.inner.inject_addr_reach_failure(peer_id, addr, error)
|
||||
}
|
||||
|
||||
fn inject_dial_failure(&mut self, peer_id: &PeerId) {
|
||||
self.inner.inject_dial_failure(peer_id)
|
||||
self.inner.inject_dial_failure(peer_id, handler, error)
|
||||
}
|
||||
|
||||
fn inject_new_listener(&mut self, id: ListenerId) {
|
||||
|
||||
Reference in New Issue
Block a user