nx_peer_piece.nx
buildroot/runtime/nx_peer_piece.nx
about
nx_peer_piece.nx -- BEP-3 REQUEST/PIECE block transfer + sha1 verify (X-TORRENT-LIVE-001 R4-b):
the actual download mechanism. interested -> unchoke -> request(index,begin,length) -> PIECE
(<index><begin><block>) -> extract block -> sha1-verify. Reuses nx_peerwire (BEP-3 build/parse,
KAT'd) + nx_sha1 (hash) -- both on the nx_syscalls layer. GATE = SOVEREIGN LOOPBACK (TCP, the
nx_peer_handshake pattern): a mock peer (listen-before-fork) completes the handshake, unchokes,
and serves a known 16-byte block in a PIECE msg; the client requests it, extracts it, and
asserts the block bytes + its sha1 match the expected. No external net; deterministic; no-hang.
license_tier: ORIGINAL
module: nishi-core.torrent.peer_piece
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
| 16 | const K_MAGIC_53377: i64 = 53377 |
| 51 | const BLK: i64 = 16 |
functions
| 18 | func pp_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 |
| 23 | func pp_wn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 24 | func pp_sockaddr(sa: *u8, port: i64, i0: i64, i1: i64, i2: i64, i3: i64) -> i64 called by 1: main |
| 31 | func pp_read_n(fd: i64, buf: *u8, n: i64) -> i64 |
| 36 | func pp_write_n(fd: i64, buf: *u8, n: i64) -> i64 called by 1: main |
| 42 | func pp_read_msg(fd: i64, mb: *u8, cap: i64) -> i64 |
| 53 | func main() -> i64 |