Expand description
Requester-side iterative FindValue lookup (ADR 022
§FIND_VALUE Flow + §Lookup integrity).
Wraps the per-RPC primitive super::client::find_value in a
standard Kademlia iteration with α=3 parallelism, three response
filters applied in order, and provider-set randomisation before
return. The lookup returns the raw surviving provider set;
ranking / probing belongs to the downstream caller.
§Termination
Stops as soon as either:
providers.len() >= k(saturation — caller has enough to probe), OR- a full round completes without surfacing any candidate strictly
closer to
targetthan the current best queried node (convergence — no further progress possible).
Mirrors the textbook Kademlia termination. The empty-providers
convergence case lets the caller fall back to the on-chain
origin-directory (super::OriginDirectory) per ADR 022 § FIND_VALUE Flow.
§Three filters (ADR 022 § Lookup integrity)
Applied in order to every FindValueResponse:
- XOR-distance — drop
closer_nodesentries whose distance to the target is not strictly less than the responder’s own distance. Honest Kademlia responders never produce such entries. - Active-staker — drop non-staked
NodeIds from bothcloser_nodesandproviders. The DHT routing pool is restricted to staked nodes by spec. - Negative probe cache — drop
(provider, target)pairs the requester has already observed returninghas_blob: falsewithin the cache TTL. Only applies toproviders, never tocloser_nodes.
After filtering, the surviving provider set is randomised before return. ADR 022 § Lookup integrity: “Randomization on the requester is the load-bearing defense against ordering manipulation.”
Structs§
- Lookup
Config - Lookup tuning knobs.
alphaandkareNonZeroUsizeso the type system rules out the silent-no-op states a zero would produce — empty batches frompick_round_batch, instant “saturation” fromhave_enough_providers. Caller-side clamping belongs at the config-parse boundary, not at every lookup entry.
Constants§
- DEFAULT_
ALPHA - Default α — parallel in-flight RPCs per round. ADR 022 § Routing Table.
- DEFAULT_
K - Default K — providers-accumulated saturation cap. ADR 022 § Routing Table.
- DEFAULT_
ROUND_ TIMEOUT - Default round timeout. Belt over the per-RPC 8s timeout in
super::client; bounds the wall-clock budget for a single iteration even if a few peers hang. - MAX_
LOOKUP_ ROUNDS - Hard ceiling on the number of rounds one lookup may run (#1145 review).
Functions§
- find_
providers - Run the iterative
FindValuelookup fortarget.