Expand description
Client-side cdn/dht/v1 request primitives.
The handler in crate::handlers::dht is the server half — it
receives FindNode / FindValue / Store / BatchStore requests
and writes responses. This module is the client half: outbound
requests issued by the bootstrap path (initial
FindNode(self.node_id)), the republish scheduler (a per-hash
Store on eager publish and one BatchStore per receiver on the
periodic drain), and the iterative requester-side FindValue lookup
in crate::dht::lookup.
Each call:
- Connects to the peer’s
EndpointAddrwith ALPNcdn/dht/v1. - Opens a bi stream.
- Writes one framed
wire::DhtMessagerequest. - Reads one framed response, decodes, and returns it.
- Closes the connection with
0u32(no app error).
The signatures mirror the server-side message types: callers
provide the request fields, get back the response struct. Error
handling surfaces via anyhow::Result; a peer that closes the
stream with an ADR 013 application error code (rate-limited,
malformed) surfaces as an anyhow error the caller logs and retries
on its next cycle.
Constants§
- DHT_
CLIENT_ TIMEOUT - Per-request hard timeout for outbound DHT exchanges. Shorter than
the sum of the server-side accept-bi timeout (5s) and read
timeout (5s) in
crate::handlers::dhtso a hung peer doesn’t wedge a republish sweep.
Functions§
- batch_
store - Send a single
BatchStorerequest totargetand return the ack (ADR 022 §STORE Flow Batched STORE). Oneboolper request hash comes back in request order. Used by the re-publish scheduler, which groups a drain cycle’s hashes by receiver and sends each receiver its set via this. Every DHT node implementsBatchStore, so there is no per-hash fallback. - find_
node - Send a single
FindNoderequest totargetand return the response. - find_
value - Send a single
FindValuerequest totargetand return the response. - store
- Send a single
Storerequest totargetand return the ack.