code wiki / _hdl_build / nx_connect_media.nx

nx_connect_media.nx

buildroot/runtime/_hdl_build/nx_connect_media.nx

6545 B122 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic connect
docsdependenciesstructsconstsfunctions

about

nx_connect_media.nx -- FUNCTIONALITY rung: media + voice-message ATTACHMENTS. The attachment system that photo/video/voice-note/file sharing is built on -- sovereign and content-blind. (The pixel/audio CODEC is a separate media substrate; this is the attachment plumbing.) Delivers + gates: CONTENT-ADDRESSED blobs (identical media stored ONCE -> dedup saves re-upload); CHUNKED + RESUMABLE transfer (split by chunk size; a partial upload resumes only the missing chunks -> large files + low-bandwidth); CONTENT-BLIND blobs (stored encrypted; server reads ZERO, client key recovers); TYPED attachments (photo/video/voice/file) with voice-note duration; and REFCOUNT tombstoning (a blob shared by N messages is collected only when the last ref drops). 7 checks incl. negative controls. 100% sovereign. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_connect_media.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap blob_put blob_find sw sys_write sn sys_mmap ↻ sys_write ↻ chunks_of blob_decrypt tcheck sw ↻ missing_chunks chunks_of ↻ attach blob_deref sys_exit

structs

none

consts

12const T_MAGIC_5001: i64 = 5001
13const T_MAGIC_2000: i64 = 2000
14const T_MAGIC_5002: i64 = 5002
16const BLK: i64 = 256 // chunk size
17const T_PHOTO: i64 = 1
18const T_VIDEO: i64 = 2
19const T_VOICE: i64 = 3
20const T_FILE: i64 = 4

functions

22func sw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: tcheckmain calls 1: sys_write
23func sn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
26func blob_find(bh: *i64, cnt: i64, hash: i64) -> i64
called by 1: blob_put
32func blob_put(bh: *i64, bs: *i64, br: *i64, bc: *i64, cntp: *i64, hash: i64, size: i64, content: i64, key: i64) -> i64
called by 1: main calls 1: blob_find
40func blob_decrypt(bc: *i64, idx: i64, key: i64) -> i64 { return bc[idx]-key }
called by 1: main
41func blob_deref(br: *i64, idx: i64) -> i64 { br[idx]=br[idx]-1; return br[idx] }
called by 1: main
42func chunks_of(size: i64) -> i64 { return (size + BLK - 1)/BLK } // ceil(size/BLK)
called by 2: missing_chunksmain
43func missing_chunks(size: i64, received: i64) -> i64 { return chunks_of(size) - received }
called by 1: main calls 1: chunks_of
45func attach(ab: *i64, aty: *i64, am: *i64, acntp: *i64, blob_idx: i64, atype: i64, meta: i64) -> i64
called by 1: main
51func tcheck(pass: i64, label: *u8, fails: *i64) -> i64
called by 1: main calls 1: sw
57func main() -> i64