Skip to main content

Module connection_tracker

Module connection_tracker 

Source
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§

PeerConnectionInfo
All tracked information for a single peer.
PeerConnectionTracker
Tracks the lifecycle of all peer connections with per-peer statistics.
TrackerStats
Aggregated statistics across all tracked peers.

Enums§

ConnectionEvent
An event that describes a state change or observation on a peer connection.
ConnectionState
The current state of a peer’s connection.