Skip to content

Commit b8a7684

Browse files
feat(swarm): remove deprecated connection limits
Users are encouraged to use `libp2p::connection_limit::Behaviour` which is a one-to-one replacement for this functionality but built as a `NetworkBehaviour`. Related: #3647. Pull-Request: #3885.
1 parent f08055e commit b8a7684

File tree

7 files changed

+48
-510
lines changed

7 files changed

+48
-510
lines changed

misc/metrics/src/swarm.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,6 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
214214
};
215215
}
216216
}
217-
#[allow(deprecated)]
218-
libp2p_swarm::DialError::ConnectionLimit(_) => {
219-
record(OutgoingConnectionError::ConnectionLimit)
220-
}
221217
libp2p_swarm::DialError::LocalPeerId { .. } => {
222218
record(OutgoingConnectionError::LocalPeerId)
223219
}
@@ -320,7 +316,6 @@ enum PeerStatus {
320316

321317
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Debug)]
322318
enum OutgoingConnectionError {
323-
ConnectionLimit,
324319
LocalPeerId,
325320
NoAddresses,
326321
DialPeerConditionFalse,
@@ -345,18 +340,13 @@ enum IncomingConnectionError {
345340
TransportErrorMultiaddrNotSupported,
346341
TransportErrorOther,
347342
Aborted,
348-
ConnectionLimit,
349343
Denied,
350344
}
351345

352346
impl From<&libp2p_swarm::ListenError> for IncomingConnectionError {
353347
fn from(error: &libp2p_swarm::ListenError) -> Self {
354348
match error {
355349
libp2p_swarm::ListenError::WrongPeerId { .. } => IncomingConnectionError::WrongPeerId,
356-
#[allow(deprecated)]
357-
libp2p_swarm::ListenError::ConnectionLimit(_) => {
358-
IncomingConnectionError::ConnectionLimit
359-
}
360350
libp2p_swarm::ListenError::LocalPeerId { .. } => IncomingConnectionError::LocalPeerId,
361351
libp2p_swarm::ListenError::Transport(
362352
libp2p_core::transport::TransportError::MultiaddrNotSupported(_),

protocols/kad/src/behaviour.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,8 +1931,6 @@ where
19311931
DialError::DialPeerConditionFalse(dial_opts::PeerCondition::Always) => {
19321932
unreachable!("DialPeerCondition::Always can not trigger DialPeerConditionFalse.");
19331933
}
1934-
#[allow(deprecated)]
1935-
DialError::ConnectionLimit(_) => {}
19361934
}
19371935
}
19381936

swarm/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@
3030
- Flatten `ConnectionHandlerUpgrErr` and rename to `StreamUpgradeError`.
3131
See [PR 3882].
3232

33+
- Remove deprecated `ConnectionLimits`.
34+
Users should migrate to `libp2p::connection_limits::Behaviour`.
35+
See [PR 3885].
36+
3337
[PR 3605]: https://github.com/libp2p/rust-libp2p/pull/3605
3438
[PR 3715]: https://github.com/libp2p/rust-libp2p/pull/3715
3539
[PR 3746]: https://github.com/libp2p/rust-libp2p/pull/3746
3640
[PR 3865]: https://github.com/libp2p/rust-libp2p/pull/3865
3741
[PR 3882]: https://github.com/libp2p/rust-libp2p/pull/3882
3842
[PR 3884]: https://github.com/libp2p/rust-libp2p/pull/3884
43+
[PR 3885]: https://github.com/libp2p/rust-libp2p/pull/3885
3944
[PR 3886]: https://github.com/libp2p/rust-libp2p/pull/3886
4045

4146
## 0.42.2

swarm/src/connection.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -400,31 +400,6 @@ impl<'a> IncomingInfo<'a> {
400400
}
401401
}
402402

403-
/// Information about a connection limit.
404-
#[deprecated(note = "Use `libp2p::connection_limits` instead.", since = "0.42.1")]
405-
#[derive(Debug, Clone, Copy)]
406-
pub struct ConnectionLimit {
407-
/// The maximum number of connections.
408-
pub limit: u32,
409-
/// The current number of connections.
410-
pub current: u32,
411-
}
412-
413-
#[allow(deprecated)]
414-
impl fmt::Display for ConnectionLimit {
415-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
416-
write!(
417-
f,
418-
"connection limit exceeded ({}/{})",
419-
self.current, self.limit
420-
)
421-
}
422-
}
423-
424-
/// A `ConnectionLimit` can represent an error if it has been exceeded.
425-
#[allow(deprecated)]
426-
impl std::error::Error for ConnectionLimit {}
427-
428403
struct SubstreamUpgrade<UserData, Upgrade> {
429404
user_data: Option<UserData>,
430405
timeout: Delay,

swarm/src/connection/error.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1919
// DEALINGS IN THE SOFTWARE.
2020

21-
#[allow(deprecated)]
22-
use crate::connection::ConnectionLimit;
2321
use crate::transport::TransportError;
2422
use crate::Multiaddr;
2523
use crate::{ConnectedPoint, PeerId};
@@ -90,15 +88,6 @@ pub enum PendingConnectionError<TTransErr> {
9088
/// An error occurred while negotiating the transport protocol(s) on a connection.
9189
Transport(TTransErr),
9290

93-
/// The connection was dropped because the connection limit
94-
/// for a peer has been reached.
95-
#[deprecated(
96-
note = "Use `libp2p::connection_limits` instead and handle `{Dial,Listen}Error::Denied::cause`.",
97-
since = "0.42.1"
98-
)]
99-
#[allow(deprecated)]
100-
ConnectionLimit(ConnectionLimit),
101-
10291
/// Pending connection attempt has been aborted.
10392
Aborted,
10493

@@ -117,10 +106,6 @@ impl<T> PendingConnectionError<T> {
117106
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> PendingConnectionError<U> {
118107
match self {
119108
PendingConnectionError::Transport(t) => PendingConnectionError::Transport(f(t)),
120-
#[allow(deprecated)]
121-
PendingConnectionError::ConnectionLimit(l) => {
122-
PendingConnectionError::ConnectionLimit(l)
123-
}
124109
PendingConnectionError::Aborted => PendingConnectionError::Aborted,
125110
PendingConnectionError::WrongPeerId { obtained, endpoint } => {
126111
PendingConnectionError::WrongPeerId { obtained, endpoint }
@@ -145,10 +130,6 @@ where
145130
"Pending connection: Transport error on connection: {err}"
146131
)
147132
}
148-
#[allow(deprecated)]
149-
PendingConnectionError::ConnectionLimit(l) => {
150-
write!(f, "Connection error: Connection limit: {l}.")
151-
}
152133
PendingConnectionError::WrongPeerId { obtained, endpoint } => {
153134
write!(
154135
f,
@@ -172,8 +153,6 @@ where
172153
PendingConnectionError::WrongPeerId { .. } => None,
173154
PendingConnectionError::LocalPeerId { .. } => None,
174155
PendingConnectionError::Aborted => None,
175-
#[allow(deprecated)]
176-
PendingConnectionError::ConnectionLimit(..) => None,
177156
}
178157
}
179158
}

0 commit comments

Comments
 (0)