Skip to content

Commit

Permalink
deps: bump sysinfo from 0.29.11 to 0.30.5
Browse files Browse the repository at this point in the history
Pull-Request: libp2p#5061.
  • Loading branch information
dependabot[bot] authored and TimTinkers committed Sep 14, 2024
1 parent 1a37a7a commit 1edd12a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
49 changes: 28 additions & 21 deletions 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 misc/memory-connection-limits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ memory-stats = { version = "1", features = ["always_use_statm"] }
libp2p-core = { workspace = true }
libp2p-swarm = { workspace = true }
libp2p-identity = { workspace = true, features = ["peerid"] }
sysinfo = "0.29"
sysinfo = "0.30"
tracing = { workspace = true }
void = "1"

Expand Down
9 changes: 6 additions & 3 deletions misc/memory-connection-limits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use std::{
task::{Context, Poll},
time::{Duration, Instant},
};
use sysinfo::MemoryRefreshKind;

/// A [`NetworkBehaviour`] that enforces a set of memory usage based limits.
///
Expand Down Expand Up @@ -90,10 +91,12 @@ impl Behaviour {
///
/// New inbound and outbound connections will be denied when the threshold is reached.
pub fn with_max_percentage(percentage: f64) -> Self {
use sysinfo::{RefreshKind, SystemExt};
use sysinfo::{RefreshKind, System};

let system_memory_bytes =
sysinfo::System::new_with_specifics(RefreshKind::new().with_memory()).total_memory();
let system_memory_bytes = System::new_with_specifics(
RefreshKind::new().with_memory(MemoryRefreshKind::new().with_ram()),
)
.total_memory();

Self::with_max_bytes((system_memory_bytes as f64 * percentage).round() as usize)
}
Expand Down
6 changes: 4 additions & 2 deletions misc/memory-connection-limits/tests/max_percentage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use libp2p_core::Multiaddr;
use libp2p_identity::PeerId;
use libp2p_memory_connection_limits::*;
use std::time::Duration;
use sysinfo::{RefreshKind, SystemExt};
use sysinfo::{MemoryRefreshKind, RefreshKind};
use util::*;

use libp2p_swarm::{
Expand All @@ -36,7 +36,9 @@ use libp2p_swarm_test::SwarmExt;
#[test]
fn max_percentage() {
const CONNECTION_LIMIT: usize = 20;
let system_info = sysinfo::System::new_with_specifics(RefreshKind::new().with_memory());
let system_info = sysinfo::System::new_with_specifics(
RefreshKind::new().with_memory(MemoryRefreshKind::new().with_ram()),
);

let mut network = Swarm::new_ephemeral(|_| TestBehaviour {
connection_limits: Behaviour::with_max_percentage(0.1),
Expand Down

0 comments on commit 1edd12a

Please sign in to comment.