code wiki / (root) / nx_peer_piece_live.nx

nx_peer_piece_live.nx

buildroot/runtime/nx_peer_piece_live.nx

12328 B179 linesdepth 7pulls 13 transitivereach 6 importersview sourcekind tooltopic peer
docsdependenciesstructsconstsfunctions

about

nx_peer_piece_live.nx -- download a REAL data piece from a REAL peer + sha1-verify it against the metadata piece hash (X-TORRENT-LIVE-001 L4a): the last engine step = real file bytes off the wire. One peer connection: BEP-3 handshake -> BEP-10 ext -> BEP-9 metadata (piece map) -> INTERESTED -> on UNCHOKE request piece 0's 16KiB blocks -> assemble -> sha1(piece0)==pieces[0]. DISPATCH state machine (real peers interleave choke/bitfield/have). Fork-bounded per peer (no-hang). Reuses nx_peer_meta_live (cl_*/pm_*) + nx_peerwire + nx_bencode + nx_sha1. GATE = LIVE: a real peer serves a sha1-verified data piece of Big Buck Bunny. license_tier: ORIGINAL module: nishi-core.torrent.peer_piece_live depends: nishi-core.torrent.peer_meta_live

dependencies 2 imports · 1 importers

nx_peer_meta_live.nx nx_connect.nx nx_peer_piece_live.nx nx_torrent_get.nx

imports: nx_peer_meta_live.nxnx_connect.nx

imported by: nx_torrent_get.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main cl_announce nx_dns_a_resolve sys_socket sys_set_socket_timeout sys_mmap sys_setsockopt sys_munmap sys_mmap ↻ da_sockaddr da_build_query da_qname sys_sendto sys_close sys_recvfrom da_parse da_u16 da_skip_name sys_socket ↻ sys_set_socket_timeout ↻ cl_sockaddr nx_udp_build_connect _ut_put_u64 _ut_put_u32 sys_sendto ↻ sys_recvfrom ↻ nx_udp_parse_connect_resp _ut_get_u32 _ut_get_u64 nx_udp_build_announce _ut_put_u64 ↻ _ut_put_u32 ↻ _ut_put_u16 nx_udp_parse_announce_resp _ut_get_u32 ↻ sys_openat_wr cl_write_n sys_fork pp_child sys_socket ↻

structs

none

consts

13const K_MAGIC_262144: i64 = 262144
14const K_MAGIC_40000: i64 = 40000
15const K_MAGIC_16383: i64 = 16383
16const K_MAGIC_16384: i64 = 16384
17const K_MAGIC_25000: i64 = 25000
31const PCAP: i64 = 33554432 // max piece buffer 32 MiB (was 4 MiB; see seq1734)

functions

34func pp_child(ipv: i64, port: i64, ih: *u8, mypid: *u8, res: *u8) -> i64
134func main() -> i64