mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-31 08:51:57 +00:00
swarm/: Rename ProtocolsHandler to ConnectionHandler (#2527)
A `ProtocolsHandler`, now `ConnectionHandler`, handels a connection, not a protocol. Thus the name `CONNECTIONHandler` is more appropriate. Next to the rename of `ProtocolsHandler` this commit renames the `mod protocols_handler` to `mod handler`. Finally all combinators (e.g. `ProtocolsHandlerSelect`) are renamed appropriately.
This commit is contained in:
@@ -28,8 +28,8 @@ use libp2p_core::multiaddr::Protocol;
|
||||
use libp2p_core::{Multiaddr, PeerId};
|
||||
use libp2p_swarm::dial_opts::{self, DialOpts};
|
||||
use libp2p_swarm::{
|
||||
DialError, IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler,
|
||||
PollParameters, ProtocolsHandler, ProtocolsHandlerUpgrErr,
|
||||
ConnectionHandler, ConnectionHandlerUpgrErr, DialError, IntoConnectionHandler,
|
||||
NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
|
||||
};
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use std::task::{Context, Poll};
|
||||
@@ -62,7 +62,7 @@ pub enum UpgradeError {
|
||||
#[error("Failed to dial peer.")]
|
||||
Dial,
|
||||
#[error("Failed to establish substream: {0}.")]
|
||||
Handler(ProtocolsHandlerUpgrErr<void::Void>),
|
||||
Handler(ConnectionHandlerUpgrErr<void::Void>),
|
||||
}
|
||||
|
||||
pub struct Behaviour {
|
||||
@@ -83,10 +83,10 @@ impl Behaviour {
|
||||
}
|
||||
|
||||
impl NetworkBehaviour for Behaviour {
|
||||
type ProtocolsHandler = handler::Prototype;
|
||||
type ConnectionHandler = handler::Prototype;
|
||||
type OutEvent = Event;
|
||||
|
||||
fn new_handler(&mut self) -> Self::ProtocolsHandler {
|
||||
fn new_handler(&mut self) -> Self::ConnectionHandler {
|
||||
handler::Prototype::UnknownConnection
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ impl NetworkBehaviour for Behaviour {
|
||||
fn inject_dial_failure(
|
||||
&mut self,
|
||||
peer_id: Option<PeerId>,
|
||||
handler: Self::ProtocolsHandler,
|
||||
handler: Self::ConnectionHandler,
|
||||
_error: &DialError,
|
||||
) {
|
||||
match handler {
|
||||
@@ -187,7 +187,7 @@ impl NetworkBehaviour for Behaviour {
|
||||
peer_id: &PeerId,
|
||||
connection_id: &ConnectionId,
|
||||
connected_point: &ConnectedPoint,
|
||||
_handler: <<Self as NetworkBehaviour>::ProtocolsHandler as IntoProtocolsHandler>::Handler,
|
||||
_handler: <<Self as NetworkBehaviour>::ConnectionHandler as IntoConnectionHandler>::Handler,
|
||||
_remaining_established: usize,
|
||||
) {
|
||||
if !connected_point.is_relayed() {
|
||||
@@ -209,7 +209,7 @@ impl NetworkBehaviour for Behaviour {
|
||||
&mut self,
|
||||
event_source: PeerId,
|
||||
connection: ConnectionId,
|
||||
handler_event: <<Self::ProtocolsHandler as IntoProtocolsHandler>::Handler as ProtocolsHandler>::OutEvent,
|
||||
handler_event: <<Self::ConnectionHandler as IntoConnectionHandler>::Handler as ConnectionHandler>::OutEvent,
|
||||
) {
|
||||
match handler_event {
|
||||
Either::Left(handler::relayed::Event::InboundConnectRequest {
|
||||
@@ -313,7 +313,7 @@ impl NetworkBehaviour for Behaviour {
|
||||
&mut self,
|
||||
_cx: &mut Context<'_>,
|
||||
poll_parameters: &mut impl PollParameters,
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
|
||||
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>> {
|
||||
if let Some(action) = self.queued_actions.pop_front() {
|
||||
return Poll::Ready(action.build(poll_parameters));
|
||||
}
|
||||
|
Reference in New Issue
Block a user