Skip to main content

Module engine

Module engine 

Source
Expand description

The PexEngine — the transport-agnostic, sans-IO core both a DIG Node and the relay embed (SPEC Appendix A).

You feed the engine four kinds of input and it returns the messages to send + the events to act on; it does no I/O itself (the node/relay do the actual dig-nat mux / WebSocket reads and writes):

  • link eventslink_up (produces our outgoing handshake + snapshot) and link_down (discards all per-link state, SPEC §5.5);
  • inbound messageson_message validates + advances the receiver state machine, returning verified-candidate / dropped events and any pex_error replies, and penalizing misbehavior (SPEC §5, §6.4, §7, §11);
  • local peer-set changesupsert_known / remove_known maintain the first-hand set PEX advertises (SPEC §9.3);
  • clock tickstick (~1/s) emits per-link pex_deltas for pending changes, spaced by the effective interval (SPEC §6).

Timestamps are Unix epoch milliseconds. See crate docs for the node vs relay embedding.

Structs§

PexConfig
Configuration for a PexEngine (SPEC Appendix A).
PexEngine
The transport-agnostic PEX engine (SPEC Appendix A). One instance per participant; it multiplexes all of that participant’s links.
PexOutcome
The result of feeding the engine an inbound message or transport error: the messages to send back on the link, plus the events for the host to act on.

Enums§

PexEvent
An event the engine surfaces from an inbound message for the host to act on (SPEC Appendix A).