Skip to main content

Module caps

Module caps 

Source
Expand description

The frozen version-1 protocol constants and the message-level cap checks (SPEC §7.1, §7.2).

These are the wire contract — an implementation is conformant only if it enforces exactly these values. Senders MUST never exceed the list caps; receivers MUST reject (never truncate) an over-cap message with a violation strike. The PexEngine enforces both directions: it caps its own outgoing messages, and it rejects over-cap inbound ones.

Constants§

PEX_ARRIVAL_GRACE
The receiver’s enforcement tolerance, in seconds — absorbs scheduling + clock skew (SPEC §6.4).
PEX_DEFAULT_INTERVAL
Default declared send interval, in seconds (SPEC §6.2).
PEX_MAX_ADDED
Maximum entries in a pex_delta.added list.
PEX_MAX_ADDRESSES
Maximum addresses per peer entry.
PEX_MAX_DROPPED
Maximum ids in a pex_delta.dropped list.
PEX_MAX_ENTRY_AGE
Maximum last_seen age (seconds) an entry may be advertised with; older entries are not advertised (sender) and skipped on receive (SPEC §3.3, §8.2).
PEX_MAX_FLAGS
Maximum flags per peer entry (and per handshake).
PEX_MAX_FLAG_LEN
Maximum characters per flag token.
PEX_MAX_FRAME
Maximum message body bytes (256 KiB) — matches the DHT / dig-nat wire bound. A frame claiming a larger body MUST be rejected before allocating or reading the body (SPEC §4.1, §7.2).
PEX_MAX_HINTS
Hard ceiling on the engine-global hints map (SPEC §9.2, §11.3) — the deduplicated best hint per peer_id across all links. Bounds total memory when many links each contribute distinct peer_ids. Oldest-last_seen entries are evicted first once the cap is reached.
PEX_MAX_INTERVAL
Interval ceiling for declarations, in seconds.
PEX_MAX_RECEIVED_PER_LINK
Hard ceiling on a single link’s received accumulator (SPEC §9.2, §11.3) — the set of peer_ids that link has told us, kept for dropped attribution. Bounds per-link memory from an authenticated peer that streams an unbounded number of distinct fresh peer_ids over the link’s lifetime; a single message is already capped by PEX_MAX_ADDED/PEX_MAX_SNAPSHOT, but that does not bound the cumulative total across many messages. Oldest-last_seen entries are evicted first once the cap is reached.
PEX_MAX_SNAPSHOT
Maximum entries in a pex_snapshot.peers list.
PEX_MIN_INTERVAL
Hard interval floor, in seconds — a sender MUST NOT declare (nor be enforced) below this.
PEX_VERSION
The PEX wire version this crate implements (SPEC §7.1).
PEX_VIOLATION_LIMIT
Strikes on a direction before it is muted / the peer may be disconnected (SPEC §7.1, §11.2).

Functions§

frame_within_bound
Whether a frame body of len bytes is within PEX_MAX_FRAME. A caller MUST check this before allocating or reading the body (the stream binding checks the length prefix; the relay binding checks the WebSocket payload length).