Crate network_utils crate

This commit is contained in:
Daniel Knopik
2025-07-18 16:47:50 +02:00
parent 1046dfbfe7
commit add4b70b0a
42 changed files with 186 additions and 149 deletions

View File

@@ -5,6 +5,8 @@ edition = { workspace = true }
[dependencies]
lighthouse_network = { workspace = true }
metrics = { workspace = true }
network_utils = { workspace = true }
parking_lot = { workspace = true }
serde = { workspace = true }
sysinfo = { workspace = true }

View File

@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::sync::Arc;
use sysinfo::{CpuExt, DiskExt, NetworkExt, NetworksExt, System, SystemExt};
use network_utils::discovery_metrics;
use types::EthSpec;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
@@ -219,29 +220,29 @@ impl NatState {
/// Observes if NAT traversal is possible.
pub fn observe_nat() -> NatState {
let discv5_ipv4 = lighthouse_network::metrics::get_int_gauge(
&lighthouse_network::metrics::NAT_OPEN,
let discv5_ipv4 = metrics::get_int_gauge(
&discovery_metrics::NAT_OPEN,
&["discv5_ipv4"],
)
.map(|g| g.get() == 1)
.unwrap_or_default();
let discv5_ipv6 = lighthouse_network::metrics::get_int_gauge(
&lighthouse_network::metrics::NAT_OPEN,
let discv5_ipv6 = metrics::get_int_gauge(
&discovery_metrics::NAT_OPEN,
&["discv5_ipv6"],
)
.map(|g| g.get() == 1)
.unwrap_or_default();
let libp2p_ipv4 = lighthouse_network::metrics::get_int_gauge(
&lighthouse_network::metrics::NAT_OPEN,
let libp2p_ipv4 = metrics::get_int_gauge(
&discovery_metrics::NAT_OPEN,
&["libp2p_ipv4"],
)
.map(|g| g.get() == 1)
.unwrap_or_default();
let libp2p_ipv6 = lighthouse_network::metrics::get_int_gauge(
&lighthouse_network::metrics::NAT_OPEN,
let libp2p_ipv6 = metrics::get_int_gauge(
&discovery_metrics::NAT_OPEN,
&["libp2p_ipv6"],
)
.map(|g| g.get() == 1)