gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] 40/49: examples/web: Don't hash the data.


From: gnunet
Subject: [gnunet-scheme] 40/49: examples/web: Don't hash the data.
Date: Sat, 25 Dec 2021 23:00:17 +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 e127bf6482ac541b3df47b5810db3bdbf17501fc
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Wed Oct 6 08:10:36 2021 +0200

    examples/web: Don't hash the data.
    
    * examples/web.scm (decode): Rename to ...
      (decode/key): ... this.
      (decode/data): New procedure.
      (process-put-dht): Use new procedure for data.
      (process-search-dht): Use new name of old procedure.
---
 examples/web.scm | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/examples/web.scm b/examples/web.scm
index e087a00..f3fdc60 100644
--- a/examples/web.scm
+++ b/examples/web.scm
@@ -102,22 +102,29 @@
        (dt "Standard deviation")
        (dd ,(number->string (nse:estimate:standard-deviation estimate)))))
 
-(define (decode encoding data)
+(define (decode/key encoding data)
   (match encoding
     ("utf-8-text"
      (hash/sha512 (bv-slice/read-write (string->utf8 data))))
     ;; TODO other encodings
     ))
 
+(define (decode/data encoding data)
+  (match encoding
+    ("utf-8-text"
+     (bv-slice/read-write (string->utf8 data))
+     ;; TODO other encodings
+     )))
+
 (define (process-put-dht dht-server parameters)
   ;; TODO replication level, expiration ...
   (dht:put! dht-server
            (string->number (assoc-ref parameters "type"))
-           (decode (assoc-ref parameters "key-encoding")
-                   ;; TODO the key is 00000.... according to gnunet-dht-monitor
-                   (assoc-ref parameters "key"))
-           (decode (assoc-ref parameters "data-encoding")
-                   (assoc-ref parameters "data"))))
+           (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 (process-search-dht dht-server parameters)
   (define what)
@@ -132,8 +139,8 @@
     (signal-condition! found?))
   (dht:start-get! dht-server
                  (string->number (assoc-ref parameters "type"))
-                 (decode (assoc-ref parameters "key-encoding")
-                         (assoc-ref parameters "key"))
+                 (decode/key (assoc-ref parameters "key-encoding")
+                             (assoc-ref parameters "key"))
                  found
                  #:desired-replication-level
                  (string->number (assoc-ref parameters "replication-level")))

-- 
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]