Skip to main content

Module protocol

Module protocol 

Source
Expand description

weirdnet-sync/v1 messages and length-prefixed CBOR framing.

After the authenticated channel is up, payloads that carry records, cursors or certificates are sealed under crate::sync_key. An Envelope carries the type and epoch in the clear so the receiver can pick the key; the body is sealed.

Structs§

Ack
Envelope
What goes on the request-response wire: type, epoch and (after a rotation) the rotation id in the clear, body sealed.
Hello
HelloOk
KeyRef
Which key an envelope is sealed under: the seed-derived one at epoch, or the rotated one with this id.
Page
Pull
Refuse
RosterMsg

Enums§

Message
Application-level message, before sealing.

Constants§

PAGE_BUDGET
Plaintext budget for the ops in one page. The sealed body is hex in the envelope (two bytes per plaintext byte), and weirdnet-net 0.8 sends the encoded envelope as one CBOR byte string (one byte per byte, a few bytes of header). So a page is about twice its plaintext on the wire, plus the envelope fields. This reserves 16 KiB for those and for the gap between LogEntry::wire_size and the real encoding (which is an estimate), then halves the rest: a full page is about 120 KiB plus slack under PAGE_MAX. (Through 0.4 this was a quarter, because 0.7 sent the bytes as integer arrays.)
PAGE_MAX
Largest sealed page on the wire (and the request and reply cap to set on a sync node).
PROTOCOL
Request-response protocol id. /2 since weirdnet-net 0.8 sends byte fields as CBOR byte strings; a 0.4 (/1) node fails to negotiate instead of failing to decode.

Statics§

SYNC_PROFILE
Identifier profile: /weirdnet/sync/2 for request-response, otherwise WEIRDNET.

Functions§

decode
decode_framed
encode
Length-prefixed CBOR (u32 big-endian length, then the item). For a raw stream; Node::request already frames Envelope as CBOR through libp2p.
encode_framed
page_for_type
Build a Page message from a log page, dropping ops whose typ does not match (they stay in the log for a later pull of that type).

Type Aliases§

Cursors
Last seq applied from each node, as sent in Hello.
RefuseReason