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

@ -23,9 +23,9 @@ use either::Either;
use libp2p_core::connection::ConnectionId;
use libp2p_core::upgrade::{self, DeniedUpgrade};
use libp2p_core::{ConnectedPoint, PeerId};
use libp2p_swarm::protocols_handler::DummyProtocolsHandler;
use libp2p_swarm::protocols_handler::SendWrapper;
use libp2p_swarm::{IntoProtocolsHandler, ProtocolsHandler};
use libp2p_swarm::handler::DummyConnectionHandler;
use libp2p_swarm::handler::SendWrapper;
use libp2p_swarm::{ConnectionHandler, IntoConnectionHandler};
pub mod direct;
pub mod relayed;
@ -43,8 +43,8 @@ pub enum Role {
Listener,
}
impl IntoProtocolsHandler for Prototype {
type Handler = Either<relayed::Handler, Either<direct::Handler, DummyProtocolsHandler>>;
impl IntoConnectionHandler for Prototype {
type Handler = Either<relayed::Handler, Either<direct::Handler, DummyConnectionHandler>>;
fn into_handler(self, _remote_peer_id: &PeerId, endpoint: &ConnectedPoint) -> Self::Handler {
match self {
@ -52,7 +52,7 @@ impl IntoProtocolsHandler for Prototype {
if endpoint.is_relayed() {
Either::Left(relayed::Handler::new(endpoint.clone()))
} else {
Either::Right(Either::Right(DummyProtocolsHandler::default()))
Either::Right(Either::Right(DummyConnectionHandler::default()))
}
}
Self::DirectConnection {
@ -68,7 +68,7 @@ impl IntoProtocolsHandler for Prototype {
}
}
fn inbound_protocol(&self) -> <Self::Handler as ProtocolsHandler>::InboundProtocol {
fn inbound_protocol(&self) -> <Self::Handler as ConnectionHandler>::InboundProtocol {
match self {
Prototype::UnknownConnection => upgrade::EitherUpgrade::A(SendWrapper(
upgrade::EitherUpgrade::A(protocol::inbound::Upgrade {}),