Expand description
Multi-strategy Peer Discovery Manager
Provides PeerDiscoveryManager — a production-grade component that tracks
peer candidates sourced from multiple discovery strategies, deduplicates
them, scores connection likelihood, and drives the connection-attempt
lifecycle from first-seen through disconnect.
§Design overview
-
Deduplication – every candidate is keyed by its peer-id string; a second
add_candidatecall for the same peer-id merges the new addresses into the existing record rather than creating a duplicate entry. -
Scoring – each candidate carries a
connect_score(∈ [0, 10]) that rises on successful connection and falls on failure, timeout, or unreachability. Candidates are ranked by score when the caller asks for connection targets. -
Backoff –
candidates_to_tryreturns only those peers whoselast_attemptis old enough (≥retry_backoff_ms) or who have never been attempted. -
Stale eviction –
evict_staleremoves non-connected candidates that were both discovered and last attempted (or never attempted) beyondstale_threshold_ms.
Structs§
- Discovery
Config - Configuration knobs for
PeerDiscoveryManager. - Discovery
Stats - Aggregated statistics snapshot returned by
PeerDiscoveryManager::stats. - Peer
Candidate - A single peer candidate tracked by
PeerDiscoveryManager. - Peer
Discovery Manager - Multi-strategy peer discovery manager.
Enums§
- Connect
Outcome - Outcome of a single connection attempt reported back to the manager.
- Discovery
Method - The mechanism through which a
PeerCandidatewas first discovered.