Expand description
The PEX wire — the four type-tagged JSON messages (SPEC §4) and their framing.
§The four messages
type | Purpose |
|---|---|
pex_handshake | first message each direction: version + network + declared interval + own flags (§4.2) |
pex_snapshot | the first data message: a capped picture of the sender’s first-hand set (§4.3) |
pex_delta | the periodic message: added / dropped relative to what this link was told (§4.4) |
pex_error | the advisory error envelope (§4.5) |
§Framing (SPEC §4.1)
- Byte stream (node↔node, §10.1):
PexMessage::encode/PexMessage::decodeframe each message as au32big-endian length prefix + JSON body — byte-identical to the dig-nat / dig-dht wires. A length prefix overcrate::caps::PEX_MAX_FRAMEis rejected without allocating the body. - Relay WebSocket (relay→node, §10.2):
PexMessage::to_json/PexMessage::from_jsoncarry the bare JSON object in one WebSocket text frame (the socket already delimits messages).
JSON shapes are frozen: the type tags and field names are the wire contract, and unknown
fields are ignored on receive (additive evolution).
Enums§
- PexMessage
- A PEX protocol message — one of the four
type-tagged shapes (SPEC §4). Thetypetag and field names are the frozen wire contract.