gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet-scheme] branch master updated (53ef1e2 -> 0ea9aa3)


From: gnunet
Subject: [gnunet-scheme] branch master updated (53ef1e2 -> 0ea9aa3)
Date: Wed, 30 Nov 2022 11:50:31 +0100

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a change to branch master
in repository gnunet-scheme.

    from 53ef1e2  Support constructing /:msg:fs:request-loc-signature (wip).
     new 538a02e  fs/struct: Export /content-hash-key.
     new 7705ec2  fs/uri: New procedure make-content-hash-key/share.
     new 0ea9aa3  fs/network: Define analyse-request-loc-signature.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 gnu/gnunet/fs/network.scm | 32 ++++++++++++++++++++++++++------
 gnu/gnunet/fs/struct.scm  |  3 ++-
 gnu/gnunet/fs/uri.scm     | 17 ++++++++++++++---
 3 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/gnu/gnunet/fs/network.scm b/gnu/gnunet/fs/network.scm
index 981ecac..4b3b01c 100644
--- a/gnu/gnunet/fs/network.scm
+++ b/gnu/gnunet/fs/network.scm
@@ -19,22 +19,25 @@
 
 ;; TODO: untested
 (define-library (gnu gnunet fs network)
-  (export construct-request-loc-signature)
-  (import (only (rnrs base) define define-syntax quote)
+  (export construct-request-loc-signature analyse-request-loc-signature)
+  (import (only (rnrs base) define define-syntax quote values)
          (only (guile) begin define*)
          (only (gnu gnunet utils bv-slice)
                make-slice/read-write slice-copy! slice-length )
+         (only (gnu gnunet utils hat-let) let^)
          (only (gnu extractor enum) value->index symbol-value)
          (only (gnu gnunet message protocols) message-type)
-         (only (gnu gnunet fs struct) /:msg:fs:request-loc-signature)
+         (only (gnu gnunet fs struct)
+               /content-hash-key /:msg:fs:request-loc-signature)
          (only (gnu gnunet fs uri)
                chk-key ;; TODO rename
-               chk-query)
+               chk-query
+               make-content-hash-key/share)
          (only (gnu gnunet hashcode)
                hashcode:512->slice)
          (only (gnu gnunet utils cut-syntax) cut-syntax)
          (only (gnu gnunet netstruct syntactic)
-               set%! sizeof select))
+               set%! sizeof select read%))
   (begin
     ;; GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT,
     ;; (see gnunet-signatures/gnunet_signatures.rst)
@@ -67,4 +70,21 @@ expiring at @var{expiration-time} (TODO type), for 
@var{purpose}
        (hashcode:512->slice (chk-query content-hash-key))
        (select* '(content-hash-key query)))
       (set%!* '(file-length) file-length)
-      s)))
+      s)
+
+   (define (analyse-request-loc-signature message)
+     "Return the file length, content hash key, expiration time (TODO type)
+and signature purpose corresponding to the 
@code{/:msg:fs:request-loc-signature}
+message @var{message}."
+     (let^ ((! file-length
+              (read% /:msg:fs:request-loc-signature '(file-length) message))
+           (! content-hash-key
+              (make-content-hash-key/share
+               (select /:msg:fs:request-loc-signature
+                       '(content-hash-key) message)))
+           (! expiration-time
+              (read% /:msg:fs:request-loc-signature
+                     '(expiration-time) message))
+           (! purpose
+              (read% /:msg:fs:request-loc-signature '(purpose) message)))
+          (values file-length content-hash-key expiration-time purpose)))))
diff --git a/gnu/gnunet/fs/struct.scm b/gnu/gnunet/fs/struct.scm
index 52639f8..c63c866 100644
--- a/gnu/gnunet/fs/struct.scm
+++ b/gnu/gnunet/fs/struct.scm
@@ -21,7 +21,8 @@
 ;; Author: Igor Wronsky, Christian Grothoff
 ;; Ported to Scheme-GNUnet by: Maxime Devos
 (define-library (gnu gnunet fs struct)
-  (export /:msg:fs:request-loc-signature
+  (export /content-hash-key
+         /:msg:fs:request-loc-signature
          /:msg:fs:response-loc-signature
          /:msg:fs:index-start!
          /:msg:fs:index-list:entry
diff --git a/gnu/gnunet/fs/uri.scm b/gnu/gnunet/fs/uri.scm
index ca3cb7a..978bd42 100644
--- a/gnu/gnunet/fs/uri.scm
+++ b/gnu/gnunet/fs/uri.scm
@@ -1,6 +1,6 @@
 ;#!r6rs
 ;;   This file is part of scheme-GNUnet, a partial Scheme port of GNUnet.
-;;   Copyright (C) 2003--2014, 2020 GNUnet e.V.
+;;   Copyright (C) 2003--2014, 2020, 2022 GNUnet e.V.
 ;;
 ;;   GNUnet is free software: you can redistribute it and/or modify it
 ;;   under the terms of the GNU Affero General Public License as published
@@ -79,17 +79,20 @@
 ;; module in the gnunetutil library and discussed there.
 
 (library (gnu gnunet fs uri (1 1))
-  (export chk? make-chk chk-key chk-query
+  (export chk? make-chk make-content-hash-key/share chk-key chk-query
           chk-uri? make-chk-uri chk-uri-file-length chk-uri-chk
          chk-uri-parse)
   (import (rnrs base)
           (rnrs records syntactic)
          (gnu gnunet hashcode)
          (gnu gnunet hashcode-ascii)
+         (only (gnu gnunet fs struct) /content-hash-key)
          ;; TODO portability
          (only (guile) make-regexp regexp-exec)
          (only (ice-9 regex) match:substring)
-         (only (srfi srfi-2) and-let*))
+         (only (srfi srfi-2) and-let*)
+         (only (gnu gnunet netstruct syntactic)
+               select))
 
   ;; Size of the individual blocks used for file-sharing.
   ;; TODO: what is the proper place to define this constant
@@ -110,6 +113,14 @@
     (assert (hashcode:512? query))
     (%make-content-hash-key key query))
 
+  (define (make-content-hash-key/share slice)
+    "Construct a <content-hash-key> corresponding to the
+@code{/content-hash-key} @var{slice}.  @var{slice} may not be modified
+while the content hash key is in use."
+    (make-chk (make-hashcode:512/share (select /content-hash-key '(key) slice))
+             (make-hashcode:512/share
+              (select /content-hash-key '(query) slice))))
+
   ;; Information needed to retrieve a file (content-hash-key
   ;; plus file size)
   (define-record-type (<chk-uri> %make-chk-uri chk-uri?)

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