refactor(core)!: remove EitherUpgrade (#3339)

We don't need to define our own type here, we can simply implement `UpgradeInfo`, `InboundUpgrade` and `OutboundUpgrade` on `either::Either`.
This commit is contained in:
Thomas Eizinger
2023-01-18 13:35:07 +11:00
committed by GitHub
parent 8cd14e6a3a
commit db2cd43826
14 changed files with 64 additions and 82 deletions

View File

@ -21,7 +21,7 @@
use crate::protocol;
use either::Either;
use libp2p_core::connection::ConnectionId;
use libp2p_core::upgrade::{self, DeniedUpgrade};
use libp2p_core::upgrade::DeniedUpgrade;
use libp2p_core::{ConnectedPoint, PeerId};
use libp2p_swarm::dummy;
use libp2p_swarm::handler::SendWrapper;
@ -70,11 +70,11 @@ impl IntoConnectionHandler for Prototype {
fn inbound_protocol(&self) -> <Self::Handler as ConnectionHandler>::InboundProtocol {
match self {
Prototype::UnknownConnection => upgrade::EitherUpgrade::A(SendWrapper(
upgrade::EitherUpgrade::A(protocol::inbound::Upgrade {}),
)),
Prototype::UnknownConnection => {
Either::Left(SendWrapper(Either::Left(protocol::inbound::Upgrade {})))
}
Prototype::DirectConnection { .. } => {
upgrade::EitherUpgrade::A(SendWrapper(upgrade::EitherUpgrade::B(DeniedUpgrade)))
Either::Left(SendWrapper(Either::Right(DeniedUpgrade)))
}
}
}