Skip to main content

Module dht_optimizer

Module dht_optimizer 

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

ConditionClassification
entry_count > k (default k=20)Saturated
any non-responsive entryStale
responsive_count < target_fillSparse
otherwiseHealthy

§Recommendation priority

  1. For each stale bucket: up to 3 PingPeer recommendations (or EvictPeer if the entry has not been seen for > 2× stale threshold).
  2. For each sparse bucket: one RefreshBucket recommendation.

Structs§

BucketAnalysis
Per-bucket analysis result produced by DhtRoutingOptimizer::analyze_bucket.
DhtRoutingOptimizer
Analyzes Kademlia routing table snapshots and emits remediation suggestions.
OptimizationReport
Summary report produced by DhtRoutingOptimizer::optimize.
RoutingEntry
A single peer entry in the Kademlia routing table snapshot.

Enums§

BucketHealth
Health classification for a single Kademlia k-bucket.
RoutingRecommendation
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.