Skip to main content

MAX_BENCODE_DEPTH

Constant MAX_BENCODE_DEPTH 

Source
pub const MAX_BENCODE_DEPTH: usize = 32;
Expand description

Deepest nesting a bencode value may use before it is refused.

Far above anything the protocols that use bencode define. KRPC’s deepest legitimate shape is the outer dict, the a/r dict inside it, and at most a list of dicts below that — four. A tracker announce reply is d → peers list → peer dict — three. 32 leaves room for an extension nobody has written yet while still being ~2000x short of the frame count that overflows a worker thread.