diff --git a/Cargo.lock b/Cargo.lock index b0879a15b40..1c84c8e2666 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3057,7 +3057,7 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.26.0" +version = "0.26.1" dependencies = [ "anyhow", "async-std", @@ -3261,7 +3261,7 @@ dependencies = [ [[package]] name = "libp2p-webrtc-utils" -version = "0.1.0" +version = "0.2.0" dependencies = [ "asynchronous-codec", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 0e812acc027..773e105cd53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -97,7 +97,7 @@ libp2p-pnet = { version = "0.24.0", path = "transports/pnet" } libp2p-quic = { version = "0.10.2", path = "transports/quic" } libp2p-relay = { version = "0.17.1", path = "protocols/relay" } libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" } -libp2p-request-response = { version = "0.26.0", path = "protocols/request-response" } +libp2p-request-response = { version = "0.26.1", path = "protocols/request-response" } libp2p-server = { version = "0.12.4", path = "misc/server" } libp2p-swarm = { version = "0.44.0", path = "swarm" } libp2p-swarm-derive = { version = "=0.34.0", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required. @@ -107,7 +107,7 @@ libp2p-tls = { version = "0.3.0", path = "transports/tls" } libp2p-uds = { version = "0.40.0", path = "transports/uds" } libp2p-upnp = { version = "0.2.0", path = "protocols/upnp" } libp2p-webrtc = { version = "0.7.0-alpha", path = "transports/webrtc" } -libp2p-webrtc-utils = { version = "0.1.0", path = "misc/webrtc-utils" } +libp2p-webrtc-utils = { version = "0.2.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.3.0-alpha", path = "transports/webrtc-websys" } libp2p-websocket = { version = "0.43.0", path = "transports/websocket" } libp2p-websocket-websys = { version = "0.3.1", path = "transports/websocket-websys" } diff --git a/misc/connection-limits/src/lib.rs b/misc/connection-limits/src/lib.rs index af76e9a57d9..cb12599ad79 100644 --- a/misc/connection-limits/src/lib.rs +++ b/misc/connection-limits/src/lib.rs @@ -79,22 +79,17 @@ impl Behaviour { established_per_peer: Default::default(), } } +} - fn check_limit( - &mut self, - limit: Option, - current: usize, - kind: Kind, - ) -> Result<(), ConnectionDenied> { - let limit = limit.unwrap_or(u32::MAX); - let current = current as u32; +fn check_limit(limit: Option, current: usize, kind: Kind) -> Result<(), ConnectionDenied> { + let limit = limit.unwrap_or(u32::MAX); + let current = current as u32; - if current >= limit { - return Err(ConnectionDenied::new(Exceeded { limit, kind })); - } - - Ok(()) + if current >= limit { + return Err(ConnectionDenied::new(Exceeded { limit, kind })); } + + Ok(()) } /// A connection limit has been exceeded. @@ -210,7 +205,7 @@ impl NetworkBehaviour for Behaviour { _: &Multiaddr, _: &Multiaddr, ) -> Result<(), ConnectionDenied> { - self.check_limit( + check_limit( self.limits.max_pending_incoming, self.pending_inbound_connections.len(), Kind::PendingIncoming, @@ -230,12 +225,12 @@ impl NetworkBehaviour for Behaviour { ) -> Result, ConnectionDenied> { self.pending_inbound_connections.remove(&connection_id); - self.check_limit( + check_limit( self.limits.max_established_incoming, self.established_inbound_connections.len(), Kind::EstablishedIncoming, )?; - self.check_limit( + check_limit( self.limits.max_established_per_peer, self.established_per_peer .get(&peer) @@ -243,7 +238,7 @@ impl NetworkBehaviour for Behaviour { .unwrap_or(0), Kind::EstablishedPerPeer, )?; - self.check_limit( + check_limit( self.limits.max_established_total, self.established_inbound_connections.len() + self.established_outbound_connections.len(), @@ -260,7 +255,7 @@ impl NetworkBehaviour for Behaviour { _: &[Multiaddr], _: Endpoint, ) -> Result, ConnectionDenied> { - self.check_limit( + check_limit( self.limits.max_pending_outgoing, self.pending_outbound_connections.len(), Kind::PendingOutgoing, @@ -280,12 +275,12 @@ impl NetworkBehaviour for Behaviour { ) -> Result, ConnectionDenied> { self.pending_outbound_connections.remove(&connection_id); - self.check_limit( + check_limit( self.limits.max_established_outgoing, self.established_outbound_connections.len(), Kind::EstablishedOutgoing, )?; - self.check_limit( + check_limit( self.limits.max_established_per_peer, self.established_per_peer .get(&peer) @@ -293,7 +288,7 @@ impl NetworkBehaviour for Behaviour { .unwrap_or(0), Kind::EstablishedPerPeer, )?; - self.check_limit( + check_limit( self.limits.max_established_total, self.established_inbound_connections.len() + self.established_outbound_connections.len(), diff --git a/misc/webrtc-utils/CHANGELOG.md b/misc/webrtc-utils/CHANGELOG.md index c3485aa1dbf..6949113a377 100644 --- a/misc/webrtc-utils/CHANGELOG.md +++ b/misc/webrtc-utils/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.0 + +- Update to latest version of `libp2p-noise`. + See [PR 4968](https://github.com/libp2p/rust-libp2p/pull/4968). + ## 0.1.0 - Initial release. diff --git a/misc/webrtc-utils/Cargo.toml b/misc/webrtc-utils/Cargo.toml index 8ae36754d0f..7173dedae7b 100644 --- a/misc/webrtc-utils/Cargo.toml +++ b/misc/webrtc-utils/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT" name = "libp2p-webrtc-utils" repository = "https://github.com/libp2p/rust-libp2p" rust-version = { workspace = true } -version = "0.1.0" +version = "0.2.0" publish = true [dependencies] diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index 30fc700da3c..d53ff479ee2 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.26.1 + +- Derive `PartialOrd` and `Ord` for `{Out,In}boundRequestId`. + See [PR 4956](https://github.com/libp2p/rust-libp2p/pull/4956). + ## 0.26.0 - Remove `request_response::Config::set_connection_keep_alive` in favor of `SwarmBuilder::idle_connection_timeout`. diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index 2c7692fb9b4..6da25e24862 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-request-response" edition = "2021" rust-version = { workspace = true } description = "Generic Request/Response Protocols" -version = "0.26.0" +version = "0.26.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/request-response/src/lib.rs b/protocols/request-response/src/lib.rs index 824839ebac8..fc68bd6cf1f 100644 --- a/protocols/request-response/src/lib.rs +++ b/protocols/request-response/src/lib.rs @@ -274,7 +274,7 @@ impl ResponseChannel { /// /// Note: [`InboundRequestId`]'s uniqueness is only guaranteed between /// inbound requests of the same originating [`Behaviour`]. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct InboundRequestId(u64); impl fmt::Display for InboundRequestId { @@ -287,7 +287,7 @@ impl fmt::Display for InboundRequestId { /// /// Note: [`OutboundRequestId`]'s uniqueness is only guaranteed between /// outbound requests of the same originating [`Behaviour`]. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct OutboundRequestId(u64); impl fmt::Display for OutboundRequestId {