nx_peer_download.nx
buildroot/runtime/nx_peer_download.nx
about
nx_peer_download.nx -- DOWNLOAD a multi-block piece off a peer + WRITE it to a LOCAL FILE,
read-back verified (X-TORRENT-LIVE-001 R5): the literal "download locally" step. Builds on R4-b:
handshake -> interested -> unchoke -> request each 16-byte block -> PIECE -> assemble the 32-byte
piece -> sha1-verify -> sys_openat_wr the piece to a local file at its offset -> read it back ->
assert on-disk bytes + sha1 match. Reuses nx_peerwire (BEP-3) + nx_sha1. GATE = SOVEREIGN LOOPBACK:
a mock peer serves the two known blocks in request order; the client downloads, assembles, writes,
and re-reads from disk. Deterministic; no external net; no-hang (timeouts). license_tier: ORIGINAL
module: nishi-core.torrent.peer_download
depends: nishi-core.torrent.peerwire, nishi-core.crypto.sha1
dependencies 4 imports · 0 importers
imports: nx_peerwire.nxnx_itoa_lib.nxnx_connect.nxnx_sha1.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 15 | const K_MAGIC_53401: i64 = 53401 |
| 49 | const BLK: i64 = 16 |
| 50 | const NBLK: i64 = 2 |
| 51 | const PIECE: i64 = 32 // BLK*NBLK |
functions
| 17 | func pd_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } called by 1: main |
| 22 | func pd_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 23 | func pd_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64 called by 1: main |
| 30 | func pd_read_n(fd: i64, buf: *u8, n: i64) -> i64 |
| 35 | func pd_write_n(fd: i64, buf: *u8, n: i64) -> i64 called by 1: main |
| 40 | func pd_read_msg(fd: i64, mb: *u8, cap: i64) -> i64 |
| 53 | func main() -> i64 |