nx_relchan.nx
buildroot/runtime/nx_relchan.nx
about
nx_relchan.nx -- sovereign RELIABLE, ORDERED, EXACTLY-ONCE channel for CRITICAL game events
(creature captured, block placed/broken, trade) over the unreliable relay. Position is unreliable-
frequent (interp/extrapolate cover its loss); events must never be lost OR double-applied. Sender
keeps an unacked window + retransmits; receiver dedups by seq + delivers strictly in order +
cumulative-acks. 100% nx, no syscalls -> wasm-friendly; the host just moves the bytes.
Receiver state r[*i64]: [0]=expected (next in-order seq) [1]=delivered_total then [2 + seq] = received-bit
(capacity seqcap). Cumulative ack = expected-1 (highest contiguous delivered).
Sender state s[*i64]: [0]=acked_upto (cumulative, -1 = none) [1]=n (event count). Resends seqs > acked_upto.
license_tier: ORIGINAL
dependencies 0 imports · 1 importers
imports: none
imported by: nx_relchan_gate.nx
structs
| none |
consts
| none |
functions
| 12 | func rc_rinit(r: *i64, seqcap: i64) -> i64 called by 1: main |
| 18 | func rc_expected(r: *i64) -> i64 { return r[0] } called by 1: main |
| 19 | func rc_delivered(r: *i64) -> i64 { return r[1] } called by 1: main |
| 20 | func rc_ack_value(r: *i64) -> i64 { return r[0] - 1 } // cumulative ack to send back called by 1: main |
| 24 | func rc_recv(r: *i64, seqcap: i64, seq: i64) -> i64 called by 1: main |
| 39 | func rc_sinit(s: *i64, n: i64) -> i64 { s[0] = 0 - 1; s[1] = n; return 0 } called by 1: main |
| 40 | func rc_ack(s: *i64, a: i64) -> i64 { if a > s[0] { s[0] = a } return 0 } called by 1: main |
| 41 | func rc_unacked_lo(s: *i64) -> i64 { return s[0] + 1 } // first seq still needing (re)send called by 1: main |
| 42 | func rc_all_acked(s: *i64) -> i64 { if s[0] >= s[1] - 1 { return 1 } return 0 } called by 1: main |