Expand description
DHT Routing Table Optimizer for Kademlia bucket health analysis.
Periodically analyzes the Kademlia routing table to identify bucket
imbalances, dead peers, and suboptimal coverage, then emits remediation
suggestions via RoutingRecommendation.
§Design
The optimizer is a pure analytical component — it does not mutate any
state. Callers feed it a snapshot of their routing table entries and
receive an OptimizationReport containing per-bucket analyses and a
prioritised list of actions to take.
§Health classification (per bucket)
| Condition | Classification |
|---|---|
entry_count > k (default k=20) | Saturated |
| any non-responsive entry | Stale |
responsive_count < target_fill | Sparse |
| otherwise | Healthy |
§Recommendation priority
- For each stale bucket: up to 3
PingPeerrecommendations (orEvictPeerif the entry has not been seen for > 2× stale threshold). - For each sparse bucket: one
RefreshBucketrecommendation.
Structs§
- Bucket
Analysis - Per-bucket analysis result produced by
DhtRoutingOptimizer::analyze_bucket. - DhtRouting
Optimizer - Analyzes Kademlia routing table snapshots and emits remediation suggestions.
- Optimization
Report - Summary report produced by
DhtRoutingOptimizer::optimize. - Routing
Entry - A single peer entry in the Kademlia routing table snapshot.
Enums§
- Bucket
Health - Health classification for a single Kademlia k-bucket.
- Routing
Recommendation - Remediation action recommended by the optimizer.
Constants§
- DEFAULT_
K_ BUCKET_ CAPACITY - Kademlia k-bucket capacity.
- DEFAULT_
STALE_ THRESHOLD_ SECS - Default number of seconds before a peer is considered stale (10 minutes).
- DEFAULT_
TARGET_ BUCKET_ FILL - Default target number of responsive peers per bucket.