nx_swarm_sim.nx
buildroot/runtime/nx_swarm_sim.nx
about
nx_swarm_sim.nx -- deterministic swarm simulator + download engine (bits-up, replayable).
module: nishi-core.torrent.swarm_sim
depends: nx_stream_picker.nx (-> nx_piece_manager), nx_syscalls.nx
capability: CORE_COMPUTE
wired_status: FULLY_WIRED
The "session loop" made TESTABLE: a discrete-round model that drives the REAL picker
(nx_sp_stream_pick / nx_pm_rarest) and the REAL endgame logic (nx_sp_in_endgame) against
a scripted swarm of honest / stalling / lying peers. Because every decision is integer and
the peer script is fixed, the whole download REPLAYS bit-for-bit -- the determinism exceed
no mainstream client has, here turned into a measurement instrument: a decision-trace hash
that must be identical across runs. This is also the substrate the benchmark grades on
(adverse-swarm completion, endgame value, streaming-to-playable). It is a SIMULATOR, not a
live client -- it measures the selection brain, honestly named as such; the live socket loop
is the named next rung.
dependencies 1 imports · 3 importers
imports: nx_stream_picker.nx
imported by: nx_swarm_sim_test.nxnx_torrent_bench.nxnx_torrent_capbench.nx
structs
| none |
consts
| 19 | const NX_MAGIC_1000000007: i64 = 1000000007 |
| 21 | const NX_SS_HONEST: i64 = 0 // delivers a requested piece it holds (verify passes) |
| 22 | const NX_SS_STALL: i64 = 1 // advertises pieces but never delivers (snub) |
| 23 | const NX_SS_LIE: i64 = 2 // advertises pieces it will not deliver / delivers corrupt (verify fails) |
| 25 | const NX_SS_DNF: i64 = 0 - 1 // did-not-finish within max_rounds (a real stall, reported honestly) |
functions
| 29 | func nx_ss_availability(peer_has: *i64, npeers: i64, n: i64, out_avail: *i64) -> i64 |
| 45 | func nx_ss_holder(peer_has: *i64, npeers: i64, n: i64, piece: i64) -> i64 |
| 55 | func nx_ss_any_honest_holder(peer_has: *i64, behavior: *i64, npeers: i64, n: i64, piece: i64) -> i64 |
| 67 | func nx_ss_outstanding(have: *i64, n: i64) -> i64 |
| 82 | func nx_ss_run(peer_has: *i64, behavior: *i64, npeers: i64, n: i64, have: *i64, |
| 125 | func nx_ss_rounds_to_playable(peer_has: *i64, behavior: *i64, npeers: i64, n: i64, have: *i64, |