diff options
| author | tv <tv@krebsco.de> | 2026-10-24 05:58:37 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 05:58:37 +0200 |
| commit | e0ab17f665bb476329e0c7f980f31bb10cbfc944 (patch) | |
| tree | d2a76c673eb19cfa2f94563178d01c9ee151962f /src/swarm | |
| parent | 78b0a3a239a4a5921a0504bc040e5303cac5b979 (diff) | |
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.
Diffstat (limited to 'src/swarm')
| -rw-r--r-- | src/swarm/peer.rs | 4 |
1 files changed, 4 insertions, 0 deletions
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; } |
