Skip to content

Commit

Permalink
feat(swarm)!: remove PollParameters
Browse files Browse the repository at this point in the history
Resolves: libp2p#3124.

Pull-Request: libp2p#4490.
  • Loading branch information
thomaseizinger committed Oct 24, 2023
1 parent a6274bd commit d424d03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 8 additions & 6 deletions src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -435,28 +435,31 @@ impl NetworkBehaviour for Behaviour {
<request_response::Behaviour<AutoNatCodec> as NetworkBehaviour>::ConnectionHandler;
type ToSwarm = Event;

fn poll(&mut self, cx: &mut Context<'_>, params: &mut impl PollParameters) -> Poll<Action> {
fn poll(
&mut self,
cx: &mut Context<'_>,
) -> Poll<ToSwarm<Self::ToSwarm, THandlerInEvent<Self>>> {
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 {
message: request_response::Message::Response { .. },
..
}
| 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(),
};
Expand Down Expand Up @@ -609,7 +612,6 @@ type Action = ToSwarm<<Behaviour as NetworkBehaviour>::ToSwarm, THandlerInEvent<
trait HandleInnerEvent {
fn handle_event(
&mut self,
params: &mut impl PollParameters,
event: request_response::Event<DialRequest, DialResponse>,
) -> VecDeque<Action>;
}
Expand Down
3 changes: 1 addition & 2 deletions src/behaviour/as_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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<DialRequest, DialResponse>,
) -> VecDeque<Action> {
match event {
Expand Down
3 changes: 1 addition & 2 deletions src/behaviour/as_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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<DialRequest, DialResponse>,
) -> VecDeque<Action> {
match event {
Expand Down

0 comments on commit d424d03

Please sign in to comment.