code wiki / _hdl_build / nx_dist_publish.nx
nx_dist_publish.nx
buildroot/runtime/_hdl_build/nx_dist_publish.nx
about
nx_dist_publish.nx -- LIB: the HUB-AS-ENABLER multi-transport publish orchestrator (operator: "when we get data
on the hub we can pass it to other systems via torrent OR download OR api OR whatever"). When a file lands, ONE
call turns it into EVERY transport at once, content-addressed:
content-id = SHA-256 of the bytes (nx_sha256, streamed 8MB -- multi-GB safe) [the CID / v2 multihash]
magnet = magnet:?xt=urn:btmh:1220<sha256hex>&dn=<name> [BitTorrent v2 -> the swarm]
download = https://nishifamily.com/dist/<cid>/<name> [direct HTTPS -> the sites daemon]
api = /api/dist/<cid> [content-addressed API]
index-row = name<TAB>cid<TAB>size<TAB>magnet<TAB>url -> the Napster-style registry (who-has-what SSOT)
Composes our shipped organs (nx_sha256; live rung wires nx_torrent_up to seed + the sites daemon to serve + the
mgmt API to register). NO TLS import -> nx_sha256 shares this unit cleanly. No main -> built via its _gate.
license_tier: ORIGINAL
dependencies 2 imports · 5 importers
imports: nx_sha256.nxnx_syscalls.nx
imported by: nx_dist_index_gate.nxnx_dist_publish_gate.nxnx_dist_publish_run.nxnx_hub_replicate.nxnx_hub_replicate_gate.nx
structs
| none |
consts
| 14 | const K_MAGIC_8388608: i64 = 8388608 |
functions
| 16 | func dp_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=(0 as u8){dst[o]=s[i];o=o+1;i=i+1} return o } |
| 17 | func dp_wdec(dst: *u8, off: i64, v: i64) -> i64 { var o: i64=off; if v==0 { dst[o]=48 as u8; return o+1 } let t:*u8=sys_mmap(24); var k:i64=0; var m:i64=v; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } var j:i64=k-1; while j>=0 { dst[o]=t[j]; o=o+1; j=j-1 } return o } calls 1: sys_mmap |
| 18 | func dp_hexenc(inp: *u8, n: i64, out: *u8) -> i64 { let hx: *u8="0123456789abcdef" as *u8; var i: i64=0; while i<n { out[i*2]=hx[((inp[i] as i64)>>4)&15]; out[i*2+1]=hx[(inp[i] as i64)&15]; i=i+1 } out[n*2]=0 as u8; return n*2 } called by 1: dp_content_id |
| 21 | func dp_content_id(path: *u8, out_hex: *u8) -> i64 called by 5: mainmainmainhr_verify_replicamain calls 8: sys_mmapsha256_initsys_openat_rdsys_readsha256_updatesys_close+2 |
| 39 | func dp_magnet(cid_hex: *u8, name: *u8, out: *u8) -> i64 |
| 45 | func dp_dl_url(cid_hex: *u8, name: *u8, out: *u8) -> i64 |
| 51 | func dp_api(cid_hex: *u8, out: *u8) -> i64 { var o: i64 = dp_cat(out, 0, "/api/dist/" as *u8); o = dp_cat(out, o, cid_hex); out[o]=0 as u8; return o } |
| 53 | func dp_index_row(name: *u8, cid_hex: *u8, size: i64, magnet: *u8, url: *u8, out: *u8) -> i64 |