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.addedlist. - PEX_
MAX_ ADDRESSES - Maximum
addressesper peer entry. - PEX_
MAX_ DROPPED - Maximum ids in a
pex_delta.droppedlist. - PEX_
MAX_ ENTRY_ AGE - Maximum
last_seenage (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
flagsper 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
hintsmap (SPEC §9.2, §11.3) — the deduplicated best hint perpeer_idacross all links. Bounds total memory when many links each contribute distinctpeer_ids. Oldest-last_seenentries 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
receivedaccumulator (SPEC §9.2, §11.3) — the set ofpeer_ids that link has told us, kept fordroppedattribution. Bounds per-link memory from an authenticated peer that streams an unbounded number of distinct freshpeer_ids over the link’s lifetime; a single message is already capped byPEX_MAX_ADDED/PEX_MAX_SNAPSHOT, but that does not bound the cumulative total across many messages. Oldest-last_seenentries are evicted first once the cap is reached. - PEX_
MAX_ SNAPSHOT - Maximum entries in a
pex_snapshot.peerslist. - 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
lenbytes is withinPEX_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).