code wiki / _hdl_build / nx_dist_index.nx
nx_dist_index.nx
buildroot/runtime/_hdl_build/nx_dist_index.nx
about
nx_dist_index.nx -- LIB: the NAPSTER-STYLE distribution INDEX (operator: "lots of peers can share with lots of
peers like napster or torrents"). The hub keeps a central registry of WHAT content exists and WHO has it, so any
peer can DISCOVER content + its holders, then transfer P2P (via the magnet/swarm the enabler minted). Two
append-only logs (additive-only, history sacred -- Cardinal 13):
CONTENT registry: name<TAB>cid<TAB>size<TAB>magnet<TAB>url\n (one row per published item; the enabler's row)
PEER registry: cid<TAB>peer\n (one row per announce = "peer HAS cid")
Publish is idempotent by cid (Cardinal 10). Search-by-name + count-holders + lookup-by-cid = the Napster query
surface. Composes the enabler (nx_dist_publish) descriptors. No TLS. license_tier: ORIGINAL
dependencies 1 imports · 5 importers
imports: nx_syscalls.nx
imported by: nx_dist_index_gate.nxnx_gossip.nxnx_gossip_gate.nxnx_hub_replicate.nxnx_hub_replicate_gate.nx
structs
| none |
consts
| none |
functions
| 11 | func di_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 12 | func di_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 } |
| 13 | func di_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 } |
| 14 | func di_memeq(a: *u8, b: *u8, n: i64) -> i64 { var i: i64=0; while i<n { if a[i]!=b[i] { return 0 } i=i+1 } return 1 } |
| 15 | func di_eol(buf: *u8, from: i64, blen: i64) -> i64 { var e: i64=from; while e<blen { if buf[e]==10 as u8 { return e } e=e+1 } return blen } |
| 16 | func di_tab(buf: *u8, from: i64, limit: i64) -> i64 { var e: i64=from; while e<limit { if buf[e]==9 as u8 { return e } e=e+1 } return limit } |
| 18 | func di_contains(hay: *u8, hlen: i64, needle: *u8) -> i64 |
| 26 | func di_count_rows(buf: *u8, blen: i64) -> i64 { var c: i64=0; var i: i64=0; while i<blen { if buf[i]==10 as u8 { c=c+1 } i=i+1 } return c } |
| 28 | func di_has_cid(buf: *u8, blen: i64, cid: *u8) -> i64 |
| 35 | func di_publish(buf: *u8, blen: i64, name: *u8, cid: *u8, size: i64, magnet: *u8, url: *u8) -> i64 |
| 46 | func di_announce(pbuf: *u8, plen: i64, cid: *u8, peer: *u8) -> i64 |
| 53 | func di_search_name(buf: *u8, blen: i64, substr: *u8) -> i64 |
| 64 | func di_count_peers(pbuf: *u8, plen: i64, cid: *u8) -> i64 |
| 76 | func di_lookup(buf: *u8, blen: i64, cid: *u8, out: *u8) -> i64 |