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 events —
link_up(produces our outgoing handshake + snapshot) andlink_down(discards all per-link state, SPEC §5.5); - inbound messages —
on_messagevalidates + advances the receiver state machine, returning verified-candidate / dropped events and anypex_errorreplies, and penalizing misbehavior (SPEC §5, §6.4, §7, §11); - local peer-set changes —
upsert_known/remove_knownmaintain the first-hand set PEX advertises (SPEC §9.3); - clock ticks —
tick(~1/s) emits per-linkpex_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).