Check-in [f5ce3e9e3a]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add /want and /fetch for manually fetching
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: f5ce3e9e3ae38dc05790444f6bc28c73f57f1a91
User & Date: bernd 2020-05-21 11:58:27
Context
2020-05-21
14:34
Bump version number check-in: 13d5969c77 user: bernd tags: trunk
11:58
Add /want and /fetch for manually fetching check-in: f5ce3e9e3a user: bernd tags: trunk
09:58
Glitch in kill-tasks removed check-in: cd536b2adb user: bernd tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to msg.fs.

324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
...
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652


653

654


655
656
657
658





659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
....
1774
1775
1776
1777
1778
1779
1780






1781
1782
1783
1784
1785
1786
1787
....
1929
1930
1931
1932
1933
1934
1935
1936










1937
1938
1939
1940
1941
1942
1943
hash: fetch#      \ list of wanted hashs->fetcher objects
\ state: want, fetching, got it
\ methods: want->fetch, fetching-progress, fetch->got it
hash: fetch-finish#
Variable fetch-queue[]

also fetcher
:noname fetching# state ! ; fetcher-class is fetch
' 2drop fetcher-class is fetching
:noname have# state ! ; fetcher-class is got-it
previous

: .@host.id ( pk+host u -- )
    '@' emit
    2dup keysize2 safe/string type '.' emit
    key2| .simple-id ;
: .ihaves ( -- )
................................................................................

: fetch-hashs ( addr u tsk pk$ -- )
    { tsk pk$ | hashs }
    fetch( ." fetch from " pk$ $@ .@host.id forth:cr )
    bounds U+DO
	net2o-code expect+slurp $10 blocksize! $A blockalign!
	I' I U+DO
	    false  I keysize have# $@ dup IF
		bounds U+DO
		    I $@ pk$ $@ str= or
		cell +LOOP
	    ELSE  2drop  THEN
	    IF
		I keysize tsk fetch-hash
		1 +to hashs
	    THEN
	    hashs $10 u>= ?LEAVE
	keysize +LOOP
	end-code| net2o:close-all
    keysize hashs *  0 to hashs  +LOOP ;

: fetch-queue ( task want# -- )
    0 .pk.host $make { tsk w^ want# w^ pk$ -- }
    want# tsk pk$ [{: tsk pk$ :}l { item }


	item $@ pk$ $@ str= ?EXIT \ don't fetch from myself

	item $@ $8 $E pk-connect? IF


	    +resend +flow-control
	    item cell+ $@ tsk item fetch-hashs
	    disconnect-me
	THEN ;] #map





    want# #frees
    pk$ $free ;

: fetch>want ( -- want# )
    { | w^ want# }
    fetch# want# [{: want# :}l
	dup cell+ $@ drop cell+ >o fetcher:state o> 0= IF
	    $@ 2dup have# #@ dup IF
		bounds U+DO
		    2dup I $@ want# #+!
		cell +LOOP  2drop
	    ELSE  2drop 2drop  THEN
	ELSE  drop  THEN ;] #map
    want# ;

fetcher-class ' new static-a with-allocater Constant fetcher-prototype
: >fetch# ( addr u -- )
    [:  2dup fetch# #@ d0= IF
	    fetcher-prototype cell- [ fetcher-class >osize @ cell+ ]L
	    2over fetch# #!
	THEN ;] resize-sema c-section  2drop ;
................................................................................
    \G chat: switch to chat with user or group
    umethod /split ( addr u -- )
    \U split                split load
    \G split: reduce distribution load by reconnecting
    umethod /have ( addr u -- )
    \U have                 print out have list
    \G have: print out the hashes and their providers






    umethod /imgs ( addr u -- )
    \U imgs                 print out img list
    \G imgs: print out hashes for album viewer
    umethod /rescan# ( addr u -- )
    \U rescan#              rescan for hashes
    \G rescan#: search the entire chat log for hashes and if you have them
    umethod /connections ( addr u -- )
................................................................................

:noname ( addr u -- )
    2drop -1 [IFDEF] android android:level# [ELSE] level# [THEN] +! ; is /bye

:noname ( addr u -- )
    2drop [:
      remote-host$ $. ." @" pubkey $@ .simple-id ." :" forth:cr
      true ;] search-context ; is /connections










}scope

: ?slash ( addr u -- addr u flag )
    over c@ dup '/' = swap '\' = or ;

Defer chat-cmd-file-execute
' execute is chat-cmd-file-execute







|

|







 







|
<
|
|
<









|
|
|
>
>
|
>
|
>
>
|
|
|
|
>
>
>
>
>







|
<
|
|
<

|







 







>
>
>
>
>
>







 







|
>
>
>
>
>
>
>
>
>
>







324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
...
629
630
631
632
633
634
635
636

637
638

639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674

675
676

677
678
679
680
681
682
683
684
685
....
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
....
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
hash: fetch#      \ list of wanted hashs->fetcher objects
\ state: want, fetching, got it
\ methods: want->fetch, fetching-progress, fetch->got it
hash: fetch-finish#
Variable fetch-queue[]

also fetcher
:noname fetching# to state ; fetcher-class is fetch
' 2drop fetcher-class is fetching
:noname have# to state ; fetcher-class is got-it
previous

: .@host.id ( pk+host u -- )
    '@' emit
    2dup keysize2 safe/string type '.' emit
    key2| .simple-id ;
: .ihaves ( -- )
................................................................................

: fetch-hashs ( addr u tsk pk$ -- )
    { tsk pk$ | hashs }
    fetch( ." fetch from " pk$ $@ .@host.id forth:cr )
    bounds U+DO
	net2o-code expect+slurp $10 blocksize! $A blockalign!
	I' I U+DO
	    false  I keysize have# $@  bounds U+DO

		I $@ pk$ $@ str= or
	    cell +LOOP

	    IF
		I keysize tsk fetch-hash
		1 +to hashs
	    THEN
	    hashs $10 u>= ?LEAVE
	keysize +LOOP
	end-code| net2o:close-all
    keysize hashs *  0 to hashs  +LOOP ;

: fetch-queue { tsk w^ want# -- }
    0 .pk.host $make { w^ pk$ }
    want# tsk pk$ [{: tsk pk$ :}l { want }
	want $@ pk$ $@ str= IF
	    msg( ." I really should have this myself" forth:cr )
	    \ don't fetch from myself
	ELSE
	    want $@ [: $8 $E pk-connect? ;] catch 0=
	    IF
		IF
		    +resend +flow-control
		    want cell+ $@ tsk want fetch-hashs
		    disconnect-me
		THEN
	    ELSE
		fetch( ." failed, doesn't connect" forth:cr )
		nothrow 2drop
	    THEN
	THEN  rdrop ;] #map
    want# #frees
    pk$ $free ;

: fetch>want ( -- want# )
    { | w^ want# }
    fetch# want# [{: want# :}l
	dup cell+ $@ drop cell+ >o fetcher:state o> 0= IF
	    $@ 2dup have# #@ bounds U+DO

		2dup I $@ want# #+!
	    cell +LOOP  2drop

	ELSE  drop  THEN ;] #map
    want# @ ;

fetcher-class ' new static-a with-allocater Constant fetcher-prototype
: >fetch# ( addr u -- )
    [:  2dup fetch# #@ d0= IF
	    fetcher-prototype cell- [ fetcher-class >osize @ cell+ ]L
	    2over fetch# #!
	THEN ;] resize-sema c-section  2drop ;
................................................................................
    \G chat: switch to chat with user or group
    umethod /split ( addr u -- )
    \U split                split load
    \G split: reduce distribution load by reconnecting
    umethod /have ( addr u -- )
    \U have                 print out have list
    \G have: print out the hashes and their providers
    umethod /want ( addr u -- )
    \U want                 print out want list
    \G want: print out the hashes I want
    umethod /fetch ( addr u -- )
    \U fetch                trigger fetching
    \G fetch: fetch the hashes I want
    umethod /imgs ( addr u -- )
    \U imgs                 print out img list
    \G imgs: print out hashes for album viewer
    umethod /rescan# ( addr u -- )
    \U rescan#              rescan for hashes
    \G rescan#: search the entire chat log for hashes and if you have them
    umethod /connections ( addr u -- )
................................................................................

:noname ( addr u -- )
    2drop -1 [IFDEF] android android:level# [ELSE] level# [THEN] +! ; is /bye

:noname ( addr u -- )
    2drop [:
      remote-host$ $. ." @" pubkey $@ .simple-id ." :" forth:cr
	true ;] search-context ; is /connections

:noname ( addr u -- )  2drop enqueue ; is /fetch

:noname ( addr u -- )  2drop
    ." Want:" forth:cr
    fetch>want { w^ want# }
    want# [: { item }
	." from " item $@ .@host.id ."  want " item cell+ $@ 85type forth:cr
    ;] #map
    want# #frees ; is /want
}scope

: ?slash ( addr u -- addr u flag )
    over c@ dup '/' = swap '\' = or ;

Defer chat-cmd-file-execute
' execute is chat-cmd-file-execute