From e0ab17f665bb476329e0c7f980f31bb10cbfc944 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 05:58:37 +0200 Subject: add traffic counter This introduces a new wrapper that counts messages and payload bytes per peer, split by kind (hello, helloReply, sync, ping, pong), each sent, received and refused. The traffic counter goes around the firewall, which means messages dropped outbound are still counted as sent, and messages dropped inbound don't count as received. --- src/swarm/peer.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/swarm/peer.rs') diff --git a/src/swarm/peer.rs b/src/swarm/peer.rs index a936fa2..3ceea3c 100644 --- a/src/swarm/peer.rs +++ b/src/swarm/peer.rs @@ -492,6 +492,10 @@ pub(crate) async fn run_peer_worker(state: AppState) { apply_forget_records(&state).await; crate::swarm::members::ensure_registered(&state).await; crate::swarm::stability::tick(&state).await; + { + let known = state.peer_states.read().await; + state.traffic.retain(|peer| known.contains_key(peer)); + } if let Some(change) = topology::refresh(&state).await { apply_neighbour_change(&state, change).await; } -- cgit v1.3.1