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:
Roman
2021-11-25 11:33:33 +03:00
committed by GitHub
parent 5e2b93c2ea
commit c5ae5190b2
21 changed files with 564 additions and 492 deletions
+15 -21
View File
@@ -1362,8 +1362,10 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
peer_id: &PeerId,
conn: &ConnectionId,
endpoint: &ConnectedPoint,
failed_addresses: Option<&Vec<Multiaddr>>,
) {
self.behaviour.inject_connection_established(peer_id, conn, endpoint)
self.behaviour
.inject_connection_established(peer_id, conn, endpoint, failed_addresses)
}
fn inject_connection_closed(
@@ -1371,8 +1373,9 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
peer_id: &PeerId,
conn: &ConnectionId,
endpoint: &ConnectedPoint,
handler: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
) {
self.behaviour.inject_connection_closed(peer_id, conn, endpoint)
self.behaviour.inject_connection_closed(peer_id, conn, endpoint, handler)
}
fn inject_connected(&mut self, peer_id: &PeerId) {
@@ -1396,12 +1399,7 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
&mut self,
cx: &mut std::task::Context,
params: &mut impl PollParameters,
) -> Poll<
NetworkBehaviourAction<
<<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::InEvent,
Self::OutEvent
>
>{
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
if let Some(message) = self.pending_messages.pop_front() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(message))
}
@@ -1562,10 +1560,10 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
let event = match self.behaviour.poll(cx, params) {
Poll::Pending => return Poll::Pending,
Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) => ev,
Poll::Ready(NetworkBehaviourAction::DialAddress { address }) =>
return Poll::Ready(NetworkBehaviourAction::DialAddress { address }),
Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }) =>
return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition }),
Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }) =>
return Poll::Ready(NetworkBehaviourAction::DialAddress { address, handler }),
Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }) =>
return Poll::Ready(NetworkBehaviourAction::DialPeer { peer_id, condition, handler }),
Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) =>
return Poll::Ready(NetworkBehaviourAction::NotifyHandler {
peer_id,
@@ -1778,17 +1776,13 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
Poll::Pending
}
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: &libp2p::swarm::DialError,
) {
self.behaviour.inject_addr_reach_failure(peer_id, addr, error)
}
fn inject_dial_failure(&mut self, peer_id: &PeerId) {
self.behaviour.inject_dial_failure(peer_id)
self.behaviour.inject_dial_failure(peer_id, handler, error);
}
fn inject_new_listener(&mut self, id: ListenerId) {