Expand description
Peer Connection Tracker
Tracks the full lifecycle of peer connections: establishment, protocol negotiation, failure, graceful close, and per-peer statistics.
§Overview
PeerConnectionTracker maintains a registry of all known peers and their current
connection state, aggregated statistics, and a bounded event log of the 500 most
recent connection events.
§Example
use ipfrs_network::connection_tracker::{
ConnectionEvent, PeerConnectionTracker,
};
let mut tracker = PeerConnectionTracker::new();
tracker.record_event(ConnectionEvent::Connected {
peer_id: "peer-1".to_string(),
address: "/ip4/127.0.0.1/tcp/4001".to_string(),
at_secs: 1_000,
});
let peers = tracker.connected_peers();
assert_eq!(peers.len(), 1);Structs§
- Peer
Connection Info - All tracked information for a single peer.
- Peer
Connection Tracker - Tracks the lifecycle of all peer connections with per-peer statistics.
- Tracker
Stats - Aggregated statistics across all tracked peers.
Enums§
- Connection
Event - An event that describes a state change or observation on a peer connection.
- Connection
State - The current state of a peer’s connection.