pub const MAX_LOOKUP_ROUNDS: u32 = 4;Expand description
Hard ceiling on the number of rounds one lookup may run (#1145 review).
Each round is individually bounded by round_timeout, but the LOOP was not: it exits on
convergence (no closer node observed, no candidates left, or K providers found), never on
a count. So the lookup’s worst case was round_timeout × (unbounded), and it runs INSIDE
the caller’s outer pull deadline — which is derived from a slack term that has to know
what discovery can cost. An unbounded term cannot be budgeted for, and
crate::selection::PULL_THROUGH_OUTER_SLACK budgeted 10 s for something that could
exceed that in a single slow round.
Kademlia converges in O(log n) rounds. For the initial deployment target — tens of
nodes on a testnet — that is ~2-3 rounds, so this ceiling clears a healthy lookup while
bounding the pathological one, which is all a deadline needs. It is NOT generous at scale:
at thousands of nodes O(log n) with α-way fan-out is already ~10 rounds, ABOVE this cap
(dht_lookup_round_ceiling is the signal that the network outgrew the constant and it —
and PULL_THROUGH_OUTER_SLACK, derived from it — must be raised).