code wiki / _hdl_build / nx_dist_index.nx

nx_dist_index.nx

buildroot/runtime/_hdl_build/nx_dist_index.nx

4999 B90 linesdepth 2pulls 2 transitivereach 5 importersview sourcekind librarytopic dist
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_dist_index.nx nx_dist_index_gate.nx nx_gossip.nx nx_gossip_gate.nx nx_hub_replicate.nx nx_hub_replicate_gate.nx

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

11func di_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
12func 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 }
13func 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 }
called by 1: di_publish calls 1: sys_mmap
14func 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 }
15func 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 }
16func 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 }
18func di_contains(hay: *u8, hlen: i64, needle: *u8) -> i64
26func 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 }
called by 3: mainmainmain
28func di_has_cid(buf: *u8, blen: i64, cid: *u8) -> i64
35func di_publish(buf: *u8, blen: i64, name: *u8, cid: *u8, size: i64, magnet: *u8, url: *u8) -> i64
46func di_announce(pbuf: *u8, plen: i64, cid: *u8, peer: *u8) -> i64
called by 1: main calls 1: di_cat
53func di_search_name(buf: *u8, blen: i64, substr: *u8) -> i64
called by 1: main calls 3: di_eoldi_tabdi_contains
64func di_count_peers(pbuf: *u8, plen: i64, cid: *u8) -> i64
called by 1: main calls 4: di_strlendi_eoldi_tabdi_memeq
76func di_lookup(buf: *u8, blen: i64, cid: *u8, out: *u8) -> i64