Commit 708f2a22 authored by Bernd Paysan's avatar Bernd Paysan

Fix dht-map for large DHTs, start fetching ids from peers instead from DHT

parent 82c62030
......@@ -145,6 +145,7 @@ cmd-class class{ msg
field: keys[]
field: log[]
field: hashs[]
field: pks[]
field: perms# \ pk -> permission map
field: mode
\ mode bits:
......
......@@ -36,7 +36,7 @@ Variable d#public \ root of public dht
I @ ?dup-IF .xt THEN
cell +LOOP
dht @ dht-size# 2/ + dht-size# 2/ bounds DO
I @ ?dup-IF action-of xt recurse THEN
I @ IF I action-of xt recurse THEN
cell +LOOP ;
\ keys are enumerated small integers
......@@ -162,7 +162,8 @@ dht-class ' new static-a with-allocater constant dummy-dht
: .host ( addr u -- ) over c@ '!' = IF .revoke EXIT THEN
2dup sigsize# - .addr$
2dup space .sigdates >host verify-host .check 2drop ;
: .owner ( addr u -- ) 2dup sigsize# - .key$
: .owner ( addr u -- ) 2dup sigsize# - ['] .key$ catch IF
2drop <err> ." invalid key" cr <default> THEN
2dup space .sigdates verify-owner .check 2drop ;
: host>$ ( addr u -- addr u' flag )
>host verify-host 0= >r sigsize# - r> ;
......@@ -214,11 +215,10 @@ dht-class ' new static-a with-allocater constant dummy-dht
: d#cleanups? ( -- )
last-d#cleanup 64@ ticks 64u< IF
d#cleanups
last-d#cleanup 64@ 64-0<> IF ['] d#cleanups catch ELSE 0 THEN
ticks config:dht-cleaninterval& 2@ d>64 64+ last-d#cleanup 64!
throw
THEN ;
\ commands for DHT
......@@ -400,8 +400,12 @@ previous
end-code| o> ;
: addme-owndht ( -- )
pk@ >d#id >o dht-host $[]off
my-addr$ [: dht-host $+[]! ;] $[]map o> ;
pk@ >d#id [: >o dht-host $[]off
my-addr$ [: dht-host $+[]! ;] $[]map o> ;] dht-sema c-section ;
: addnick-owndht ( addr u -- )
2dup sigpk2size# - + keysize2 >d#id
[: >o [: 2dup sigpk2size# - type + sigsize# - sigsize# type ;] $tmp
dht-owner o> $rep[]sig ;] dht-sema c-section ;
\ replace me stuff
......
......@@ -455,6 +455,8 @@ Variable secret-nicks#
cell+ ..nick ." ' ok" cr ;
Forward dht-nick?
Forward addnick-owndht
Variable keysearchs#
hash: unknown-keys#
......@@ -719,6 +721,7 @@ key-entry-table $save
: key:nest-sig ( addr u -- addr u' flag )
pk2-sig? dup ?EXIT drop
2dup addnick-owndht
2dup + sigsize# - sigsize# >$
sigpk2size# - 2dup + keysize2 key?new n:>o $> ke-selfsig $!
sim-nick! off c-state off sig-ok ;
......
......@@ -1275,18 +1275,36 @@ previous
msg-group-o .msg:keys[] $[]# IF drop 0 THEN
THEN
REPEAT 2drop ;
: ?scan-pks ( addr u -- )
bounds U+DO
I $@ sigpk2size# - + keysize 2dup key# #@ d0= IF
msg-group-o .msg:pks[] $ins[] drop
THEN
cell +LOOP ;
: fetch-pks ( -- )
msg-group-o .msg:pks[] $@len 0<>
msg-group-o .msg:peers[] $@len 0<> and IF
0 msg-group-o .msg:peers[] $[] @ >o o to connection
0 msg-group-o .msg:pks[] $@ bounds U+DO
dup 0= IF 1+ net2o-code expect-reply THEN
I $@ $, dht-id dht-owner? end-with
dup 4 = IF cookie+request end-code| drop 0 THEN
cell +LOOP o>
msg-group-o .msg:pks[] $[]free
THEN ;
: msg-tredisplay ( n -- )
reset-time
msg-group-o >o msg:?otr msg:-otr o> >r
[: cells >r msg-log@
{ log u } u r> - 0 max { u' } log u' ?search-lock
log u u' /string bounds ?DO
I log - cell/ to log#
I $@ { d: msgt }
msgt ['] msg:display catch IF ." invalid entry" cr
2drop THEN
cell +LOOP
log free throw ;] catch
[: cells >r msg-log@
{ log u } log u ?scan-pks fetch-pks
u r> - 0 max { u' } log u' ?search-lock
log u u' /string bounds ?DO
I log - cell/ to log#
I $@ { d: msgt }
msgt ['] msg:display catch IF ." invalid entry" cr
2drop THEN
cell +LOOP
log free throw ;] catch
r> IF msg-group-o .msg:+otr THEN throw ;
' msg-tredisplay msg-class is msg:redisplay
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment