code wiki / _hdl_build / nx_connect_media.nx
nx_connect_media.nx
buildroot/runtime/_hdl_build/nx_connect_media.nx
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
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
structs
| none |
consts
| 12 | const T_MAGIC_5001: i64 = 5001 |
| 13 | const T_MAGIC_2000: i64 = 2000 |
| 14 | const T_MAGIC_5002: i64 = 5002 |
| 16 | const BLK: i64 = 256 // chunk size |
| 17 | const T_PHOTO: i64 = 1 |
| 18 | const T_VIDEO: i64 = 2 |
| 19 | const T_VOICE: i64 = 3 |
| 20 | const T_FILE: i64 = 4 |
functions
| 22 | func sw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 23 | func 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 } |
| 26 | func blob_find(bh: *i64, cnt: i64, hash: i64) -> i64 called by 1: blob_put |
| 32 | func blob_put(bh: *i64, bs: *i64, br: *i64, bc: *i64, cntp: *i64, hash: i64, size: i64, content: i64, key: i64) -> i64 |
| 40 | func blob_decrypt(bc: *i64, idx: i64, key: i64) -> i64 { return bc[idx]-key } called by 1: main |
| 41 | func blob_deref(br: *i64, idx: i64) -> i64 { br[idx]=br[idx]-1; return br[idx] } called by 1: main |
| 42 | func chunks_of(size: i64) -> i64 { return (size + BLK - 1)/BLK } // ceil(size/BLK) |
| 43 | func missing_chunks(size: i64, received: i64) -> i64 { return chunks_of(size) - received } |
| 45 | func attach(ab: *i64, aty: *i64, am: *i64, acntp: *i64, blob_idx: i64, atype: i64, meta: i64) -> i64 called by 1: main |
| 51 | func tcheck(pass: i64, label: *u8, fails: *i64) -> i64 |
| 57 | func main() -> i64 |