Skip to main content

Module dht

Module dht 

Source
Expand description

cdn/dht/v1 handler (ADR 022) — Kademlia content discovery.

Request handling:

  • FindNode honored against the in-memory routing table.
  • Store admission runs the full ADR 022 pipeline: holder == authenticated NodeId, active-staker filter, per-publisher quota (200), global LRU (100k), per-hash provider cap (50), receiver- anchored TTL (1 h).
  • FindValue consults the record store + the routing table; per ADR 022 §Lookup integrity the requester-side filters (XOR-distance, active-staker, negative-probe-cache, randomisation) are the requester’s job and live in the iterative-lookup module (crate::dht::lookup).
  • BatchStore admission (ADR 022 §Batch token accounting, #648): one batch-level holder == authenticated NodeId check (mismatch closes the stream with MALFORMED_MESSAGE), two-stage rate-limit accounting (stage 1 charged the inbound frame in serve; stage 2 charges up to n-1 more, partially admitting the batch under budget), then per-hash insert sharing one receiver-anchored receive_us. The reply is a BatchStoreAck with one bool per request hash, in request order. An oversize batch (> MAX_BATCH_STORE_HASHES) is rejected at wire decode with MALFORMED_MESSAGE.
  • Response variants arriving on a server-accepted stream are rejected with APP_ERR_UNSUPPORTED_MESSAGE.

Structs§

DhtHandler
Serves cdn/dht/v1. Owns the routing table + the per-request rate limiter; accept() is reentrant — many concurrent streams from different peers all share the same Arc<DhtHandler>.