mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-12 09:31:20 +00:00
{core,swarm}: Remove Network abstraction (#2492)
This commit removes the `Network` abstraction, thus managing `Listeners` and the connection `Pool` in `Swarm` directly. This is done under the assumption that noone uses the `Network` abstraction directly, but instead everyone always uses it through `Swarm`. Both `Listeners` and `Pool` are moved from `libp2p-core` into `libp2p-swarm`. Given that they are no longer exposed via `Network`, they can be treated as an implementation detail of `libp2p-swarm` and `Swarm`. This change does not include any behavioural changes. This change has the followin benefits: - Removal of `NetworkEvent`, which was mostly an isomorphism of `SwarmEvent`. - Removal of the never-directly-used `Network` abstraction. - Removal of now obsolete verbose `Peer` (`core/src/network/peer.rs`) construct. - Removal of `libp2p-core` `DialOpts`, which is a direct mapping of `libp2p-swarm` `DialOpts`. - Allowing breaking changes to the connection handling and `Swarm` API interface without a breaking change in `libp2p-core` and thus a without a breaking change in `/transport` protocols. This change enables the following potential future changes: - Removal of `NodeHandler` and `ConnectionHandler`. Thus allowing to rename `ProtocolsHandler` into `ConnectionHandler`. - Moving `NetworkBehaviour` and `ProtocolsHandler` into `libp2p-core`, having `libp2p-xxx` protocol crates only depend on `libp2p-core` and thus allowing general breaking changes to `Swarm` without breaking all `libp2p-xxx` crates.
This commit is contained in:
@ -316,29 +316,27 @@ enum PendingInboundConnectionError {
|
||||
ConnectionLimit,
|
||||
}
|
||||
|
||||
impl<TTransErr> From<&libp2p_core::connection::PendingInboundConnectionError<TTransErr>>
|
||||
impl<TTransErr> From<&libp2p_swarm::PendingInboundConnectionError<TTransErr>>
|
||||
for PendingInboundConnectionError
|
||||
{
|
||||
fn from(error: &libp2p_core::connection::PendingInboundConnectionError<TTransErr>) -> Self {
|
||||
fn from(error: &libp2p_swarm::PendingInboundConnectionError<TTransErr>) -> Self {
|
||||
match error {
|
||||
libp2p_core::connection::PendingInboundConnectionError::WrongPeerId { .. } => {
|
||||
libp2p_swarm::PendingInboundConnectionError::WrongPeerId { .. } => {
|
||||
PendingInboundConnectionError::WrongPeerId
|
||||
}
|
||||
libp2p_core::connection::PendingInboundConnectionError::ConnectionLimit(_) => {
|
||||
libp2p_swarm::PendingInboundConnectionError::ConnectionLimit(_) => {
|
||||
PendingInboundConnectionError::ConnectionLimit
|
||||
}
|
||||
libp2p_core::connection::PendingInboundConnectionError::Transport(
|
||||
libp2p_swarm::PendingInboundConnectionError::Transport(
|
||||
libp2p_core::transport::TransportError::MultiaddrNotSupported(_),
|
||||
) => PendingInboundConnectionError::TransportErrorMultiaddrNotSupported,
|
||||
libp2p_core::connection::PendingInboundConnectionError::Transport(
|
||||
libp2p_swarm::PendingInboundConnectionError::Transport(
|
||||
libp2p_core::transport::TransportError::Other(_),
|
||||
) => PendingInboundConnectionError::TransportErrorOther,
|
||||
libp2p_core::connection::PendingInboundConnectionError::Aborted => {
|
||||
libp2p_swarm::PendingInboundConnectionError::Aborted => {
|
||||
PendingInboundConnectionError::Aborted
|
||||
}
|
||||
libp2p_core::connection::PendingInboundConnectionError::IO(_) => {
|
||||
PendingInboundConnectionError::Io
|
||||
}
|
||||
libp2p_swarm::PendingInboundConnectionError::IO(_) => PendingInboundConnectionError::Io,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user