Skip to content

Commit

Permalink
feat(connection-limit): add function to mutate ConnectionLimits
Browse files Browse the repository at this point in the history
Resolves: #4826.

Pull-Request: #4964.
  • Loading branch information
dariusc93 authored Dec 4, 2023
1 parent 2b28970 commit 111f9b1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ futures-bounded = { version = "0.2.3", path = "misc/futures-bounded" }
libp2p = { version = "0.53.2", path = "libp2p" }
libp2p-allow-block-list = { version = "0.3.0", path = "misc/allow-block-list" }
libp2p-autonat = { version = "0.12.0", path = "protocols/autonat" }
libp2p-connection-limits = { version = "0.3.0", path = "misc/connection-limits" }
libp2p-connection-limits = { version = "0.3.1", path = "misc/connection-limits" }
libp2p-core = { version = "0.41.2", path = "core" }
libp2p-dcutr = { version = "0.11.0", path = "protocols/dcutr" }
libp2p-dns = { version = "0.41.1", path = "transports/dns" }
Expand Down
5 changes: 5 additions & 0 deletions misc/connection-limits/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.3.1

- Add function to mutate `ConnectionLimits`.
See [PR 4964](https://github.com/libp2p/rust-libp2p/pull/4964).

## 0.3.0


Expand Down
2 changes: 1 addition & 1 deletion misc/connection-limits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "libp2p-connection-limits"
edition = "2021"
rust-version = { workspace = true }
description = "Connection limits for libp2p."
version = "0.3.0"
version = "0.3.1"
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["peer-to-peer", "libp2p", "networking"]
Expand Down
6 changes: 6 additions & 0 deletions misc/connection-limits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ impl Behaviour {
established_per_peer: Default::default(),
}
}

/// Returns a mutable reference to [`ConnectionLimits`].
/// > **Note**: A new limit will not be enforced against existing connections.
pub fn limits_mut(&mut self) -> &mut ConnectionLimits {
&mut self.limits
}
}

fn check_limit(limit: Option<u32>, current: usize, kind: Kind) -> Result<(), ConnectionDenied> {
Expand Down

0 comments on commit 111f9b1

Please sign in to comment.