macula_peering_conn (macula v11.4.0)
View SourcePer-peer connection state machine.
Implements the lifecycle from Part 4 §10 simplified for Phase 1: no REFRESH phase and no RECONNECTING. The handshake is the post-quantum one of plans/DESIGN_PQ_HANDSHAKE_FRAMES.md, built and checked by macula_handshake: the client sends an opener, the station a challenge, the client CONNECT and the station HELLO. After HELLO each side sends a status frame at every reissue of its statement, and the connection closes when the peer's statement lapses (status_expired) or the peer's binding reaches its not_after (binding_expired). Close reasons are local: the controlling process and diagnostics hear them, the peer does not. In pq_hybrid every control frame on the open connection carries a neighbour signature for the connection and its seq in that direction.
State graph:
client: connecting → handshaking → connected → draining → (terminate)
server: awaiting_start → handshaking → connected → draining → (terminate)
Summary
Types
-type connect_opts() :: #{host := binary() | string(), port := inet:port_number(), alpn => [binary()], timeout_ms => timeout(), expected_node_id := <<_:256>>, _ => _}.
-type opts() :: #{role := client | server, identity := macula_node_keys:node_key(), issuer := pid(), capabilities := non_neg_integer(), controlling_pid := pid(), target => connect_opts(), quic_conn => reference(), puzzle => #{mode := macula_handshake:puzzle_mode()}, clock => fun(() -> integer()), accept_owner => pid(), dht_recipient => pid() | atom(), pubsub_recipient => pid() | atom(), timing_enabled => boolean(), liveness_interval_ms => pos_integer(), liveness_max_misses => pos_integer()}.