From 2384c7292e501af7de0d79e58991885660c72e45 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 24 Jan 2023 13:33:14 +1100 Subject: [PATCH 1/5] Remove unused error variant --- misc/metrics/src/swarm.rs | 2 -- swarm/CHANGELOG.md | 5 +++++ swarm/src/connection/error.rs | 7 ------- swarm/src/lib.rs | 1 - 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/misc/metrics/src/swarm.rs b/misc/metrics/src/swarm.rs index 354f05366cb..cb376cbaeb2 100644 --- a/misc/metrics/src/swarm.rs +++ b/misc/metrics/src/swarm.rs @@ -364,7 +364,6 @@ enum PendingInboundConnectionError { TransportErrorMultiaddrNotSupported, TransportErrorOther, Aborted, - Io, ConnectionLimit, } @@ -386,7 +385,6 @@ impl From<&libp2p_swarm::PendingInboundConnectionError> for PendingInboundConnec libp2p_swarm::PendingInboundConnectionError::Aborted => { PendingInboundConnectionError::Aborted } - libp2p_swarm::PendingInboundConnectionError::IO(_) => PendingInboundConnectionError::Io, } } } diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 0d2a38d65f6..143f68f2f4e 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -23,6 +23,10 @@ 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 XXXX]. + [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 @@ -31,6 +35,7 @@ [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 XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX # 0.41.1 diff --git a/swarm/src/connection/error.rs b/swarm/src/connection/error.rs index 9226035968c..7b9217ad352 100644 --- a/swarm/src/connection/error.rs +++ b/swarm/src/connection/error.rs @@ -101,10 +101,6 @@ pub enum PendingConnectionError { 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 PendingConnectionError { @@ -118,7 +114,6 @@ impl PendingConnectionError { PendingConnectionError::WrongPeerId { obtained, endpoint } => { PendingConnectionError::WrongPeerId { obtained, endpoint } } - PendingConnectionError::IO(e) => PendingConnectionError::IO(e), } } } @@ -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!( @@ -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, diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index ee8a28081ab..6026d8d3eb3 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -1611,7 +1611,6 @@ impl From for DialError { PendingConnectionError::WrongPeerId { obtained, endpoint } => { DialError::WrongPeerId { obtained, endpoint } } - PendingConnectionError::IO(e) => DialError::ConnectionIo(e), PendingConnectionError::Transport(e) => DialError::Transport(e), } } From 49d2326f11633e55ce89ef4a267703b6f748742a Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 24 Jan 2023 13:35:38 +1100 Subject: [PATCH 2/5] Apply suggestions from code review --- swarm/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 143f68f2f4e..b05af853d39 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -25,7 +25,7 @@ - Remove `PendingConnectionError:::IO` variant. This was never constructed. - See [PR XXXX]. + See [PR 3373]. [PR 3364]: https://github.com/libp2p/rust-libp2p/pull/3364 [PR 3170]: https://github.com/libp2p/rust-libp2p/pull/3170 @@ -35,7 +35,7 @@ [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 XXXX]: https://github.com/libp2p/rust-libp2p/pull/XXXX +[PR 3373]: https://github.com/libp2p/rust-libp2p/pull/3373 # 0.41.1 From 494d1314d65a282e2b8db71c73cd8b16ab66c5dd Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 24 Jan 2023 13:55:03 +1100 Subject: [PATCH 3/5] Remove unused `DialError::ConnectionIo` variant --- misc/metrics/src/swarm.rs | 4 ---- protocols/kad/src/behaviour.rs | 1 - swarm/src/lib.rs | 7 ------- 3 files changed, 12 deletions(-) diff --git a/misc/metrics/src/swarm.rs b/misc/metrics/src/swarm.rs index cb376cbaeb2..09950bc7956 100644 --- a/misc/metrics/src/swarm.rs +++ b/misc/metrics/src/swarm.rs @@ -246,9 +246,6 @@ impl super::Recorder { record(OutgoingConnectionErrorError::WrongPeerId) } - libp2p_swarm::DialError::ConnectionIo(_) => { - record(OutgoingConnectionErrorError::ConnectionIo) - } }; } libp2p_swarm::SwarmEvent::BannedPeer { endpoint, .. } => { @@ -347,7 +344,6 @@ enum OutgoingConnectionErrorError { Aborted, InvalidPeerId, WrongPeerId, - ConnectionIo, TransportMultiaddrNotSupported, TransportOther, } diff --git a/protocols/kad/src/behaviour.rs b/protocols/kad/src/behaviour.rs index 66e1b426ad7..7f4c147aebe 100644 --- a/protocols/kad/src/behaviour.rs +++ b/protocols/kad/src/behaviour.rs @@ -1936,7 +1936,6 @@ where | DialError::InvalidPeerId { .. } | DialError::WrongPeerId { .. } | DialError::Aborted - | DialError::ConnectionIo(_) | DialError::Transport(_) | DialError::NoAddresses => { if let DialError::Transport(addresses) = error { diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 6026d8d3eb3..6e478d9dca5 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -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)>), } @@ -1637,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): [")?; @@ -1678,7 +1672,6 @@ impl error::Error for DialError { DialError::Aborted => None, DialError::InvalidPeerId { .. } => None, DialError::WrongPeerId { .. } => None, - DialError::ConnectionIo(_) => None, DialError::Transport(_) => None, } } From e389876bb0dcfd503bdceca31b35af7352ed9f80 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 24 Jan 2023 13:56:55 +1100 Subject: [PATCH 4/5] add changelog entry --- swarm/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index b05af853d39..281f2b77da2 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -27,6 +27,10 @@ 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 @@ -36,6 +40,7 @@ [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 From f5c2a0e39d744951b4e648d7009a33447601aaf6 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Tue, 24 Jan 2023 13:57:10 +1100 Subject: [PATCH 5/5] Fix missing colon --- swarm/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swarm/CHANGELOG.md b/swarm/CHANGELOG.md index 281f2b77da2..1378832e7af 100644 --- a/swarm/CHANGELOG.md +++ b/swarm/CHANGELOG.md @@ -27,7 +27,7 @@ This was never constructed. See [PR 3373]. -- Remove `DialError:ConnectionIo` variant. +- Remove `DialError::ConnectionIo` variant. This was never constructed. See [PR 3374].