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:
Max Inden
2022-02-21 13:32:24 +01:00
committed by GitHub
parent 6511e6ba45
commit fd2be38faf
50 changed files with 924 additions and 910 deletions

View File

@ -42,7 +42,7 @@ use libp2p_core::{
};
use libp2p_swarm::{
dial_opts::{self, DialOpts},
IntoProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, PollParameters,
};
use wasm_timer::Instant;
@ -3051,10 +3051,10 @@ where
C: Send + 'static + DataTransform,
F: Send + 'static + TopicSubscriptionFilter,
{
type ProtocolsHandler = GossipsubHandler;
type ConnectionHandler = GossipsubHandler;
type OutEvent = GossipsubEvent;
fn new_handler(&mut self) -> Self::ProtocolsHandler {
fn new_handler(&mut self) -> Self::ConnectionHandler {
GossipsubHandler::new(
self.config.protocol_id_prefix().clone(),
self.config.max_transmit_size(),
@ -3156,7 +3156,7 @@ where
peer_id: &PeerId,
connection_id: &ConnectionId,
endpoint: &ConnectedPoint,
_: <Self::ProtocolsHandler as IntoProtocolsHandler>::Handler,
_: <Self::ConnectionHandler as IntoConnectionHandler>::Handler,
remaining_established: usize,
) {
// Remove IP from peer scoring system
@ -3443,7 +3443,7 @@ where
&mut self,
cx: &mut Context<'_>,
_: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ProtocolsHandler>> {
) -> Poll<NetworkBehaviourAction<Self::OutEvent, Self::ConnectionHandler>> {
if let Some(event) = self.events.pop_front() {
return Poll::Ready(event.map_in(|e: Arc<GossipsubHandlerIn>| {
// clone send event reference if others references are present