gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] branch master updated: dht: Use <insertion> for insertio


From: gnunet
Subject: [gnunet-scheme] branch master updated: dht: Use <insertion> for insertions.
Date: Mon, 27 Dec 2021 09:57:52 +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.

The following commit(s) were added to refs/heads/master by this push:
     new 2f3145d  dht: Use <insertion> for insertions.
2f3145d is described below

commit 2f3145d63458d95508a91281e53c2d860de1c69c
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Mon Dec 27 08:56:23 2021 +0000

    dht: Use <insertion> for insertions.
    
    * gnu/gnunet/dht/client.scm (put!): Use <insertion> objects.
    * examples/web.scm (process-put-dht, start): Adjust to new DHT API.
---
 examples/web.scm          | 22 +++++++++++++---------
 gnu/gnunet/dht/client.scm | 26 ++++++++++++--------------
 2 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/examples/web.scm b/examples/web.scm
index 13a0916..01021c4 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -121,12 +121,14 @@ for success is used."
 (define (process-put-dht dht-server parameters)
   ;; TODO replication level, expiration ...
   (dht:put! dht-server
-           (string->number (assoc-ref parameters "type"))
-           (decode/key (assoc-ref parameters "key-encoding")
-                       ;; TODO the key is 00000.... according to 
gnunet-dht-monitor
-                       (assoc-ref parameters "key"))
-           (decode/data (assoc-ref parameters "data-encoding")
-                        (assoc-ref parameters "data"))))
+           (dht:datum->insertion
+            (dht:make-datum
+             (string->number (assoc-ref parameters "type"))
+             (decode/key (assoc-ref parameters "key-encoding")
+                         ;; TODO the key is 00000.... according to 
gnunet-dht-monitor
+                         (assoc-ref parameters "key"))
+             (decode/data (assoc-ref parameters "data-encoding")
+                          (assoc-ref parameters "data"))))))
 
 (define (try-utf8->string bv) ; TODO: less duplication
   (catch 'decoding-error
@@ -238,9 +240,11 @@ If incorrect, return @code{#false}. TODO more validation."
   ;; TODO: Form to start GET and PUT requests?
   ;; For now, hard code the data to insert.
   (dht:put! dht-server
-           (symbol-value block-type block:test)
-           (bv-slice/read-write (make-bytevector 64))
-           (bv-slice/read-write #vu8(#xde #xad #xbe #xef)))
+           (dht:datum->insertion
+            (dht:make-datum
+             (symbol-value block-type block:test)
+             (bv-slice/read-write (make-bytevector 64))
+             (bv-slice/read-write #vu8(#xde #xad #xbe #xef)))))
   (dht:start-get! dht-server
                  (dht:make-query
                   (symbol-value block-type block:test)
diff --git a/gnu/gnunet/dht/client.scm b/gnu/gnunet/dht/client.scm
index bd2b226..f898494 100644
--- a/gnu/gnunet/dht/client.scm
+++ b/gnu/gnunet/dht/client.scm
@@ -344,31 +344,29 @@ as the underlying buffer might be reused.)"
       (trigger-condition! (server-new-get-operation-trigger server))
       handle)
 
-    (define* (put! server type key data #:key (desired-replication-level 3)
-                  (confirmed values))
-      "Perform an asynchronous PUT operation on the DHT, inserting @var{data}
-(a readable bytevector slice) under @var{key} (a readable bytevector slice
-holding a @code{/hashcode:512}).  The block type is @var{type} (a
-@code{block-type} or its numeric value).
-
-TODO expiration, replication, confirm ..."
+    (define* (put! server insertion #:key (confirmed values))
+      "Perform an asynchronous PUT operation on the DHT, inserting
+the information described by @var{insertion} into the DHT.
+
+TODO @var{confirmed} ..."
       ;; Prepare the message to send.
+      (define datum (insertion->datum insertion))
       (define put-message
        (make-slice/read-write (+ (sizeof /:msg:dht:client:put '())
-                                 (slice-length data))))
+                                 (slice-length (datum-value datum)))))
       (define meta (slice-slice put-message 0
                                (sizeof /:msg:dht:client:put '())))
       (set%! /:msg:dht:client:put '(header type) meta
             (value->index (symbol-value message-type msg:dht:client:put)))
       (set%! /:msg:dht:client:put '(header size) meta (slice-length 
put-message))
-      (set%! /:msg:dht:client:put '(type) meta (pk 'can (canonical-block-type 
type)))
+      (set%! /:msg:dht:client:put '(type) meta (datum-type datum))
       (set%! /:msg:dht:client:put '(option) meta 0) ; TODO
       (set%! /:msg:dht:client:put '(desired-replication-level) meta
-            desired-replication-level)
-      (set%! /:msg:dht:client:put '(expiration) meta 0) ; TODO
+            (insertion-desired-replication-level insertion))
+      (set%! /:msg:dht:client:put '(expiration) meta (datum-expiration datum))
       ;; Copy key-data pair to insert into the DHT.
-      (slice-copy! key (select /:msg:dht:client:put '(key) meta))
-      (slice-copy! data
+      (slice-copy! (datum-key datum) (select /:msg:dht:client:put '(key) meta))
+      (slice-copy! (datum-value datum)
                   (slice-slice put-message (sizeof /:msg:dht:client:put '())))
       (define handle (%make-put server confirmed put-message))
       (hashq-set! (server-new-put-operations server) handle #t)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]