Skip to main content

Module connection

Module connection 

Source
Expand description

The CONNECT/HELLO handshake and the application-frame stream abstraction, ported from src/peering/macula_peering_conn.erl (macula-io/macula) — see plans/PLAN_WIRE_PROTOCOL.md §3.

Only the client role’s connecting -> handshaking -> connected path is implemented. FrameStream is the reusable “send/receive signed application frames on one QUIC stream” primitive — Session wraps one for the control stream, and Session::open_dedicated_stream hands out fresh ones for content transfer (§12) and streaming RPC (§13), which both run on dedicated streams rather than the control stream.

Structs§

FrameStream
Session
A completed, handshaked connection to a macula-station. Holds the open control stream (CONNECT/HELLO already exchanged) and the station’s identity as verified by the HELLO frame’s own signature.

Enums§

CallError
HandshakeError
RecvEventError
RecvFrameError
RunSubscriberError
Errors from Session::run_subscriber.
SendFrameError
ServeCallError

Constants§

DEFAULT_CALL_TIMEOUT
Default timeout for a single CALL awaiting its RESULT/ERROR. Not from the reference source (macula’s own CALL timeout is caller-supplied per-call via deadline_ms inside the frame itself, not a transport- level default) — a reasonable local default for this crate’s API.
HANDSHAKE_TIMEOUT
Matches HANDSHAKE_TIMEOUT_MS in macula_peering_conn.erl: CONNECT -> HELLO is sub-second on a healthy peer; this is generous. The most common real-world trigger for hitting it is a protocol version mismatch — bytes accumulate but never form a valid frame, so the station-side symptom and this crate’s symptom are the same shape.

Functions§

connect
Dial host:port and complete the full CONNECT/HELLO handshake: open a QUIC connection, open the control stream, send a signed CONNECT built from identity, and wait for a HELLO whose own signature verifies against the node_id it claims.

Type Aliases§

BoxFuture
A boxed, 'static future — hand-rolled rather than pulling in the futures crate for one type alias.
CallHandler
Answers one inbound CALL. Ok(payload) sends a RESULT; Err(reason) sends an ERROR (BOLT#4 unknown_error, detail = reason); a panic inside the handler (caught via tokio::spawn, the same “one transient task per call” shape macula_station_link.erl uses one process per call for) is sent as ERROR temporary_relay_failure — matching that module’s own safe_invoke_handler/4 mapping exactly (including sending no detail on a crash, since the reference doesn’t either — it only logs locally).