Expand description
The peer-stream RPC framing — how a typed JSON-RPC call rides one mux stream.
dig-rpc is an HTTP JSON-RPC server; the peer surface instead carries JSON-RPC over dig-nat’s
multiplexed mTLS streams. dig-peer defines that on-stream framing here and is the CLIENT that
speaks it. Each call opens ONE fresh logical stream, writes a single length-prefixed request body,
reads a single length-prefixed response body, and lets the stream close — a clean request/response
per stream, with concurrency provided by the mux (open many streams).
§Framing (normative)
A body is a u32 big-endian length prefix followed by that many bytes — the SAME uniform framing
dig-nat’s control messages use, so the two never disagree. For an unsealed (public-read)
call the body is the JSON of a JsonRpcRequest/JsonRpcResponse. For a directed (sealed)
call the body is the byte-serialized sealed dig_message envelope wrapping that JSON (§5.4).
The MAX_BODY bound guards against a malicious length prefix forcing a huge allocation.
Constants§
- MAX_
BODY - Maximum length-prefixed body dig-peer will read — guards against a hostile length prefix. Matches dig-nat’s control-frame bound (64 KiB) for small control/RPC messages.
Functions§
- from_
json - Deserialize a JSON body from the wire into a typed value.
- read_
framed - Read one length-prefixed body (
u32big-endian length + bytes) fromr, bounded byMAX_BODY. - to_json
- Serialize a value to a JSON body for the wire.
- write_
framed - Write a length-prefixed body (
u32big-endian length + bytes) tow.