Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(swarm): remove unused DialError::ConnectionIo variant #3374

Merged
merged 8 commits into from
Jan 26, 2023
6 changes: 0 additions & 6 deletions misc/metrics/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
libp2p_swarm::DialError::WrongPeerId { .. } => {
record(OutgoingConnectionErrorError::WrongPeerId)
}
libp2p_swarm::DialError::ConnectionIo(_) => {
record(OutgoingConnectionErrorError::ConnectionIo)
}
};
}
libp2p_swarm::SwarmEvent::BannedPeer { endpoint, .. } => {
Expand Down Expand Up @@ -347,7 +344,6 @@ enum OutgoingConnectionErrorError {
Aborted,
InvalidPeerId,
WrongPeerId,
ConnectionIo,
TransportMultiaddrNotSupported,
TransportOther,
}
Expand All @@ -364,7 +360,6 @@ enum PendingInboundConnectionError {
TransportErrorMultiaddrNotSupported,
TransportErrorOther,
Aborted,
Io,
ConnectionLimit,
}

Expand All @@ -386,7 +381,6 @@ impl From<&libp2p_swarm::PendingInboundConnectionError> for PendingInboundConnec
libp2p_swarm::PendingInboundConnectionError::Aborted => {
PendingInboundConnectionError::Aborted
}
libp2p_swarm::PendingInboundConnectionError::IO(_) => PendingInboundConnectionError::Io,
}
}
}
Expand Down
1 change: 0 additions & 1 deletion protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,6 @@ where
| DialError::InvalidPeerId { .. }
| DialError::WrongPeerId { .. }
| DialError::Aborted
| DialError::ConnectionIo(_)
| DialError::Transport(_)
| DialError::NoAddresses => {
if let DialError::Transport(addresses) = error {
Expand Down
10 changes: 10 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
If you have previously set `connection_event_buffer_size` you should re-evaluate what a good size for a _per connection_ buffer is.
See [PR 3188].

- Remove `PendingConnectionError:::IO` variant.
This was never constructed.
See [PR 3373].

- Remove `DialError::ConnectionIo` variant.
This was never constructed.
See [PR 3374].

[PR 3364]: https://github.com/libp2p/rust-libp2p/pull/3364
[PR 3170]: https://github.com/libp2p/rust-libp2p/pull/3170
[PR 3134]: https://github.com/libp2p/rust-libp2p/pull/3134
Expand All @@ -31,6 +39,8 @@
[PR 3272]: https://github.com/libp2p/rust-libp2p/pull/3272
[PR 3327]: https://github.com/libp2p/rust-libp2p/pull/3327
[PR 3188]: https://github.com/libp2p/rust-libp2p/pull/3188
[PR 3373]: https://github.com/libp2p/rust-libp2p/pull/3373
[PR 3374]: https://github.com/libp2p/rust-libp2p/pull/3374

# 0.41.1

Expand Down
7 changes: 0 additions & 7 deletions swarm/src/connection/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ pub enum PendingConnectionError<TTransErr> {
obtained: PeerId,
endpoint: ConnectedPoint,
},

/// An I/O error occurred on the connection.
// TODO: Eventually this should also be a custom error?
IO(io::Error),
}

impl<T> PendingConnectionError<T> {
Expand All @@ -118,7 +114,6 @@ impl<T> PendingConnectionError<T> {
PendingConnectionError::WrongPeerId { obtained, endpoint } => {
PendingConnectionError::WrongPeerId { obtained, endpoint }
}
PendingConnectionError::IO(e) => PendingConnectionError::IO(e),
}
}
}
Expand All @@ -129,7 +124,6 @@ where
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
PendingConnectionError::IO(err) => write!(f, "Pending connection: I/O error: {err}"),
PendingConnectionError::Aborted => write!(f, "Pending connection: Aborted."),
PendingConnectionError::Transport(err) => {
write!(
Expand All @@ -156,7 +150,6 @@ where
{
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
PendingConnectionError::IO(err) => Some(err),
PendingConnectionError::Transport(_) => None,
PendingConnectionError::WrongPeerId { .. } => None,
PendingConnectionError::Aborted => None,
Expand Down
8 changes: 0 additions & 8 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1597,8 +1597,6 @@ pub enum DialError {
obtained: PeerId,
endpoint: ConnectedPoint,
},
/// An I/O error occurred on the connection.
ConnectionIo(io::Error),
/// An error occurred while negotiating the transport protocol(s) on a connection.
Transport(Vec<(Multiaddr, TransportError<io::Error>)>),
}
Expand All @@ -1611,7 +1609,6 @@ impl From<PendingOutboundConnectionError> for DialError {
PendingConnectionError::WrongPeerId { obtained, endpoint } => {
DialError::WrongPeerId { obtained, endpoint }
}
PendingConnectionError::IO(e) => DialError::ConnectionIo(e),
PendingConnectionError::Transport(e) => DialError::Transport(e),
}
}
Expand All @@ -1638,10 +1635,6 @@ impl fmt::Display for DialError {
f,
"Dial error: Unexpected peer ID {obtained} at {endpoint:?}."
),
DialError::ConnectionIo(e) => write!(
f,
"Dial error: An I/O error occurred on the connection: {e:?}."
),
DialError::Transport(errors) => {
write!(f, "Failed to negotiate transport protocol(s): [")?;

Expand Down Expand Up @@ -1679,7 +1672,6 @@ impl error::Error for DialError {
DialError::Aborted => None,
DialError::InvalidPeerId { .. } => None,
DialError::WrongPeerId { .. } => None,
DialError::ConnectionIo(_) => None,
DialError::Transport(_) => None,
}
}
Expand Down