code wiki / (root) / nx_relchan.nx

nx_relchan.nx

buildroot/runtime/nx_relchan.nx

2217 B42 linesdepth 0pulls 0 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_relchan.nx nx_relchan_gate.nx

imports: none

imported by: nx_relchan_gate.nx

structs

none

consts

none

functions

12func rc_rinit(r: *i64, seqcap: i64) -> i64
called by 1: main
18func rc_expected(r: *i64) -> i64 { return r[0] }
called by 1: main
19func rc_delivered(r: *i64) -> i64 { return r[1] }
called by 1: main
20func rc_ack_value(r: *i64) -> i64 { return r[0] - 1 } // cumulative ack to send back
called by 1: main
24func rc_recv(r: *i64, seqcap: i64, seq: i64) -> i64
called by 1: main
39func rc_sinit(s: *i64, n: i64) -> i64 { s[0] = 0 - 1; s[1] = n; return 0 }
called by 1: main
40func rc_ack(s: *i64, a: i64) -> i64 { if a > s[0] { s[0] = a } return 0 }
called by 1: main
41func rc_unacked_lo(s: *i64) -> i64 { return s[0] + 1 } // first seq still needing (re)send
called by 1: main
42func rc_all_acked(s: *i64) -> i64 { if s[0] >= s[1] - 1 { return 1 } return 0 }
called by 1: main