Skip to main content

Module peer_discovery_manager

Module peer_discovery_manager 

Source
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_candidate call 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.

  • Backoffcandidates_to_try returns only those peers whose last_attempt is old enough (≥ retry_backoff_ms) or who have never been attempted.

  • Stale evictionevict_stale removes non-connected candidates that were both discovered and last attempted (or never attempted) beyond stale_threshold_ms.

Structs§

DiscoveryConfig
Configuration knobs for PeerDiscoveryManager.
DiscoveryStats
Aggregated statistics snapshot returned by PeerDiscoveryManager::stats.
PeerCandidate
A single peer candidate tracked by PeerDiscoveryManager.
PeerDiscoveryManager
Multi-strategy peer discovery manager.

Enums§

ConnectOutcome
Outcome of a single connection attempt reported back to the manager.
DiscoveryMethod
The mechanism through which a PeerCandidate was first discovered.