From d424d03e23c6767a34dde084d511e1b131087ae1 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 25 Oct 2023 04:28:26 +1100 Subject: [PATCH] feat(swarm)!: remove `PollParameters` Resolves: #3124. Pull-Request: #4490. --- src/behaviour.rs | 14 ++++++++------ src/behaviour/as_client.rs | 3 +-- src/behaviour/as_server.rs | 3 +-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/behaviour.rs b/src/behaviour.rs index 439543f8318..e0e311e3666 100644 --- a/src/behaviour.rs +++ b/src/behaviour.rs @@ -40,7 +40,7 @@ use libp2p_swarm::{ ExternalAddrExpired, FromSwarm, }, ConnectionDenied, ConnectionId, ListenAddresses, NetworkBehaviour, NewExternalAddrCandidate, - PollParameters, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, + THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }; use std::{ collections::{HashMap, HashSet, VecDeque}, @@ -435,13 +435,16 @@ impl NetworkBehaviour for Behaviour { as NetworkBehaviour>::ConnectionHandler; type ToSwarm = Event; - fn poll(&mut self, cx: &mut Context<'_>, params: &mut impl PollParameters) -> Poll { + fn poll( + &mut self, + cx: &mut Context<'_>, + ) -> Poll>> { loop { if let Some(event) = self.pending_actions.pop_front() { return Poll::Ready(event); } - match self.inner.poll(cx, params) { + match self.inner.poll(cx) { Poll::Ready(ToSwarm::GenerateEvent(event)) => { let actions = match event { request_response::Event::Message { @@ -449,14 +452,14 @@ impl NetworkBehaviour for Behaviour { .. } | request_response::Event::OutboundFailure { .. } => { - self.as_client().handle_event(params, event) + self.as_client().handle_event(event) } request_response::Event::Message { message: request_response::Message::Request { .. }, .. } | request_response::Event::InboundFailure { .. } => { - self.as_server().handle_event(params, event) + self.as_server().handle_event(event) } request_response::Event::ResponseSent { .. } => VecDeque::new(), }; @@ -609,7 +612,6 @@ type Action = ToSwarm<::ToSwarm, THandlerInEvent< trait HandleInnerEvent { fn handle_event( &mut self, - params: &mut impl PollParameters, event: request_response::Event, ) -> VecDeque; } diff --git a/src/behaviour/as_client.rs b/src/behaviour/as_client.rs index e57523afaf8..45608ea98fd 100644 --- a/src/behaviour/as_client.rs +++ b/src/behaviour/as_client.rs @@ -30,7 +30,7 @@ use instant::Instant; use libp2p_core::Multiaddr; use libp2p_identity::PeerId; use libp2p_request_response::{self as request_response, OutboundFailure, RequestId}; -use libp2p_swarm::{ConnectionId, ListenAddresses, PollParameters, ToSwarm}; +use libp2p_swarm::{ConnectionId, ListenAddresses, ToSwarm}; use rand::{seq::SliceRandom, thread_rng}; use std::{ collections::{HashMap, HashSet, VecDeque}, @@ -101,7 +101,6 @@ pub(crate) struct AsClient<'a> { impl<'a> HandleInnerEvent for AsClient<'a> { fn handle_event( &mut self, - _: &mut impl PollParameters, event: request_response::Event, ) -> VecDeque { match event { diff --git a/src/behaviour/as_server.rs b/src/behaviour/as_server.rs index 09c70a27e93..b4c67a6a350 100644 --- a/src/behaviour/as_server.rs +++ b/src/behaviour/as_server.rs @@ -30,7 +30,7 @@ use libp2p_request_response::{ }; use libp2p_swarm::{ dial_opts::{DialOpts, PeerCondition}, - ConnectionId, DialError, PollParameters, ToSwarm, + ConnectionId, DialError, ToSwarm, }; use std::{ collections::{HashMap, HashSet, VecDeque}, @@ -95,7 +95,6 @@ pub(crate) struct AsServer<'a> { impl<'a> HandleInnerEvent for AsServer<'a> { fn handle_event( &mut self, - _params: &mut impl PollParameters, event: request_response::Event, ) -> VecDeque { match event {