pub struct CachedPeer {
pub peer_id: PeerId,
pub addresses: Vec<SocketAddr>,
pub capabilities: PeerCapabilities,
pub first_seen: SystemTime,
pub last_seen: SystemTime,
pub last_attempt: Option<SystemTime>,
pub stats: ConnectionStats,
pub quality_score: f64,
pub source: PeerSource,
pub relay_paths: Vec<RelayPathHint>,
pub token: Option<Vec<u8>>,
}Expand description
A cached peer entry with quality metrics
Fields§
§peer_id: PeerIdUnique peer identifier (serialized as bytes)
addresses: Vec<SocketAddr>Known socket addresses for this peer
capabilities: PeerCapabilitiesPeer capabilities and features
first_seen: SystemTimeWhen we first discovered this peer
last_seen: SystemTimeWhen we last successfully communicated with this peer
last_attempt: Option<SystemTime>When we last attempted to connect (success or failure)
stats: ConnectionStatsConnection statistics
quality_score: f64Computed quality score (0.0 to 1.0)
source: PeerSourceSource that added this peer
relay_paths: Vec<RelayPathHint>Known relay paths for reaching this peer when direct connection fails
token: Option<Vec<u8>>Persistent QUIC address validation token
Implementations§
Source§impl CachedPeer
impl CachedPeer
Sourcepub fn new(
peer_id: PeerId,
addresses: Vec<SocketAddr>,
source: PeerSource,
) -> Self
pub fn new( peer_id: PeerId, addresses: Vec<SocketAddr>, source: PeerSource, ) -> Self
Create a new peer entry
Sourcepub fn record_success(&mut self, rtt_ms: u32, caps: Option<PeerCapabilities>)
pub fn record_success(&mut self, rtt_ms: u32, caps: Option<PeerCapabilities>)
Record a successful connection
Sourcepub fn record_failure(&mut self)
pub fn record_failure(&mut self)
Record a failed connection attempt
Sourcepub fn calculate_quality(&mut self, weights: &QualityWeights)
pub fn calculate_quality(&mut self, weights: &QualityWeights)
Calculate quality score based on metrics
Sourcepub fn success_rate(&self) -> f64
pub fn success_rate(&self) -> f64
Get success rate
Sourcepub fn preferred_addresses(&self) -> Vec<SocketAddr>
pub fn preferred_addresses(&self) -> Vec<SocketAddr>
Return candidate addresses ordered by freshest reachability evidence first.
This prefers peer-verified reachable and externally observed addresses,
but still falls back to the persisted addresses list so unverified peers
remain dialable.
Sourcepub fn merge_addresses(&mut self, other: &CachedPeer)
pub fn merge_addresses(&mut self, other: &CachedPeer)
Merge addresses from another peer entry
Trait Implementations§
Source§impl Clone for CachedPeer
impl Clone for CachedPeer
Source§fn clone(&self) -> CachedPeer
fn clone(&self) -> CachedPeer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more