[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 20/49: dht/client: Call the callback on the client resul
From: |
gnunet |
Subject: |
[gnunet-scheme] 20/49: dht/client: Call the callback on the client result. |
Date: |
Sat, 25 Dec 2021 22:59:57 +0100 |
This is an automated email from the git hooks/post-receive script.
maxime-devos pushed a commit to branch master
in repository gnunet-scheme.
commit 891e3ea4c0fe704542e202b3f8520fd1b2366410
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat Sep 25 13:45:07 2021 +0200
dht/client: Call the callback on the client result.
* gnu/gnunet/dht/client.scm
(start-get!): Document arguments of callback.
(reconnect)[process-client-result]: New procedure.
---
gnu/gnunet/dht/client.scm | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/gnu/gnunet/dht/client.scm b/gnu/gnunet/dht/client.scm
index 0bf6045..4ee6655 100644
--- a/gnu/gnunet/dht/client.scm
+++ b/gnu/gnunet/dht/client.scm
@@ -168,7 +168,15 @@
"Perform an asynchronous GET operation on the DHT, and return a handle
to control the GET operation. Search for a block of type @var{type} (a
@code{block-type} or its numeric value) and key @var{key}, a readable
bytevector
-slice. Call @var{found} on every search result."
+slice. Call the procedure @var{found} on every search result.
+
+This procedure is called as @code((found type key data expiration get-path
put-path)w},
+where @var{key}, @var{data}, @var{get-path} and @var{put-path} are readable
+bytevector slices and @var{type} is the numeric value of the block type.
+(TODO: why does the DHT service include the key and type?).
+
+These slices must not be used after @var{found} returns, as the underlying
buffer
+might be reused."
;; TODO: options, xquery ...
(unless (= (slice-length key) (sizeof /hashcode:512 '()))
(error "length of key incorrect"))
@@ -271,6 +279,32 @@ even if not connected. This is an idempotent operation."
id->operation-map
#:key (spawn spawn-fiber)
#:rest rest)
+ (define (process-client-result handle slice)
+ "Process a reply @var{slice} (a @code{/:msg:dht:client:result}
+structure) to the get request @var{handle}."
+ (define header (slice/read-only slice 0
+ (sizeof /:msg:dht:client:result '())))
+ (define rest (slice/read-only slice
+ (sizeof /:msg:dht:client:result '())))
+ (define put-path-length
+ (read% /:msg:dht:client:result '(put-path-length) header))
+ (define get-path-length
+ (read% /:msg:dht:client:result '(get-path-length) header))
+ (define put-path
+ (slice-slice rest 0 (* (sizeof /peer-identity '()) put-path-length)))
+ (define get-path
+ (slice-slice rest (* (sizeof /peer-identity '()) put-path-length)
+ (* (sizeof /peer-identity '()) get-path-length)))
+ (define data
+ (slice-slice rest (* (sizeof /peer-identity '())
+ (+ put-path-length get-path-length))))
+ ;; TODO: maybe validate 'key' and 'type'
+ ((get:iterator handle)
+ (read% /:msg:dht:client:result '(type) header)
+ (select /:msg:dht:client:result '(key) header)
+ data
+ (read% /:msg:dht:client:result '(expiration) header)
+ get-path put-path))
(define handlers
(message-handlers
(message-handler
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 02/49: bv-slice: Support signed integers., (continued)
- [gnunet-scheme] 02/49: bv-slice: Support signed integers., gnunet, 2021/12/25
- [gnunet-scheme] 05/49: Define block types., gnunet, 2021/12/25
- [gnunet-scheme] 03/49: netstruct/procedural: Support signed integers., gnunet, 2021/12/25
- [gnunet-scheme] 08/49: examples: Consider extending the web interface with other services., gnunet, 2021/12/25
- [gnunet-scheme] 07/49: dht/client: Implement reconnecting., gnunet, 2021/12/25
- [gnunet-scheme] 09/49: examples/web: Connect to the DHT service., gnunet, 2021/12/25
- [gnunet-scheme] 10/49: dht/client: Register new get operations for processing., gnunet, 2021/12/25
- [gnunet-scheme] 12/49: dht/client: Send messages for new get operations., gnunet, 2021/12/25
- [gnunet-scheme] 13/49: dht/client: Send PUT messages., gnunet, 2021/12/25
- [gnunet-scheme] 24/49: examples/web: Put different information on separate pages., gnunet, 2021/12/25
- [gnunet-scheme] 20/49: dht/client: Call the callback on the client result.,
gnunet <=
- [gnunet-scheme] 17/49: dht/struct: Fix typo in synopsis., gnunet, 2021/12/25
- [gnunet-scheme] 14/49: Merge branch 'master' into dht, gnunet, 2021/12/25
- [gnunet-scheme] 22/49: examples/web: Make a non-functional web form for searching the DHT., gnunet, 2021/12/25
- [gnunet-scheme] 27/49: examples/web: Process DHT insertion forms., gnunet, 2021/12/25
- [gnunet-scheme] 40/49: examples/web: Don't hash the data., gnunet, 2021/12/25
- [gnunet-scheme] 35/49: examples/web: Allow module reloading., gnunet, 2021/12/25
- [gnunet-scheme] 23/49: examles/web: Add a non-functional form for DHT insertions., gnunet, 2021/12/25
- [gnunet-scheme] 15/49: Update copyright notices, gnunet, 2021/12/25
- [gnunet-scheme] 34/49: crypto: Implement functional variants., gnunet, 2021/12/25
- [gnunet-scheme] 33/49: examples/web: Hash free-form text first., gnunet, 2021/12/25