[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 07/08: dht/client: Define equality procedure for datums.
From: |
gnunet |
Subject: |
[gnunet-scheme] 07/08: dht/client: Define equality procedure for datums. |
Date: |
Thu, 09 Feb 2023 15:48:04 +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 903c860f20c46f242611050a9b56d1e705bdeca6
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Thu Feb 9 15:43:12 2023 +0100
dht/client: Define equality procedure for datums.
Simplifies tests, and is more consistent with other cisw types.
* gnu/gnunet/dht/client.scm (datum=?): New procedure.
* doc/distributed-hash-table.tm: Document it.
* tests/distributed-hash-table.scm: Use it, instead of local definition.
---
doc/distributed-hash-table.tm | 5 +++--
gnu/gnunet/dht/client.scm | 15 ++++++++++-----
tests/distributed-hash-table.scm | 3 ---
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/doc/distributed-hash-table.tm b/doc/distributed-hash-table.tm
index 4ba3ae0..da57120 100644
--- a/doc/distributed-hash-table.tm
+++ b/doc/distributed-hash-table.tm
@@ -48,8 +48,9 @@
procedures <scm|datum-type><index|datum-type>,
<scm|datum-key><index|datum-key>, <scm|datum-value><index|datum-value>,
<scm|datum-expiration><index|datum-expiration>,
- <scm|datum?><index|datum?>, <scm|make-datum> and
- <scm|make-datum/share><index|make-datum/share> have the usual semantics.
+ <scm|datum?><index|datum?>, <scm|make-datum>,
+ <scm|make-datum/share><index|make-datum/share> and
+ <scm|datum=?><index|datum=?> have the usual semantics.
The length of <var|value> may be at most
<scm|%max-datum-value-length><index|%max-datum-value-length>. If this
diff --git a/gnu/gnunet/dht/client.scm b/gnu/gnunet/dht/client.scm
index ea3a0eb..da1c606 100644
--- a/gnu/gnunet/dht/client.scm
+++ b/gnu/gnunet/dht/client.scm
@@ -41,7 +41,7 @@
malformed-path-what malformed-path-size
make-datum make-datum/share datum? datum-type datum-key datum-value
- datum-expiration
+ datum-expiration datum=?
datum->insertion insertion? insertion->datum
insertion-desired-replication-level
make-query query? query-type query-key query-desired-replication-level
@@ -112,7 +112,7 @@
(only (gnu gnunet utils bv-slice)
slice-length slice/read-only make-slice/read-write slice-copy!
slice-slice verify-slice-readable slice-copy/read-write
- slice-copy/read-only)
+ slice-copy/read-only slice-contents-equal?)
(gnu gnunet utils hat-let)
(only (gnu gnunet utils records)
define-record-type*)
@@ -222,13 +222,17 @@ appropriate exception."
#:copy (copy-datum
"Make a copy of the datum, such that modifications to the slices
in the original do not impact the copy.")
+ #:equality datum=?
#:field (type #:copy identity
+ #:equality =
#:getter datum-type
#:preprocess canonical-block-type)
#:field (key #:copy copy-hashcode:512
+ #:equality hashcode:512=?
#:getter datum-key
#:preprocess validate-key)
#:field (value #:copy slice-copy/read-only
+ #:equality slice-contents-equal?
#:getter datum-value
#:preprocess
(=>
@@ -239,6 +243,7 @@ in the original do not impact the copy.")
(make-overly-large-datum
type (slice-length value)))))))
#:field (expiration #:copy identity
+ #:equality =
#:getter datum-expiration))
;; TODO default expiration
@@ -251,9 +256,9 @@ The keyword argument expiration is optional, see ?.
Datums are @acronym{cisw} objects and as such the procedures
@code{datum-type}, @code{datum-key}, @code{datum-value},
@code{datum-expiration}, @code{datum?}, @cod€{make-datum} and
-@code{make-datum/share} have the usual semantics. The length of value may be
-at most @code{%max-datum-value-length}. If this bound is exceeded, an
-appropriate @code{&overly-large-datum} and @code{&who} condition is raised in
+@code{make-datum/share} and @datum=?} have the usual semantics. The length of
+value may be at most @code{%max-datum-value-length}. If this bound is exceeded,
+an appropriate @code{&overly-large-datum} and @code{&who} condition is raised
in
the constructor."
(%make-datum type key value expiration))
diff --git a/tests/distributed-hash-table.scm b/tests/distributed-hash-table.scm
index fccfe68..367d530 100644
--- a/tests/distributed-hash-table.scm
+++ b/tests/distributed-hash-table.scm
@@ -266,9 +266,6 @@
(define (query=? x y)
(equal? (query->sexp x) (query->sexp y)))
-(define (datum=? x y)
- (equal? (datum->sexp x) (datum->sexp y)))
-
(define (search-result=? x y)
(equal? (search-result->sexp x) (search-result->sexp y)))
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] branch master updated (86e6038 -> 671b95d), gnunet, 2023/02/09
- [gnunet-scheme] 04/08: utils/records: Give preprocessors access to previous fields., gnunet, 2023/02/09
- [gnunet-scheme] 02/08: utils/records: Fix auto-generated constructor/copy docstring., gnunet, 2023/02/09
- [gnunet-scheme] 03/08: utils/records: Support copying when #:read-only-slice-wrapper=#false., gnunet, 2023/02/09
- [gnunet-scheme] 01/08: WIP new construct + analyse, gnunet, 2023/02/09
- [gnunet-scheme] 07/08: dht/client: Define equality procedure for datums.,
gnunet <=
- [gnunet-scheme] 06/08: doc/distributed-hash-table: Normalise language for normalisation of type., gnunet, 2023/02/09
- [gnunet-scheme] 08/08: dht/client: Fix typo: € -> e., gnunet, 2023/02/09
- [gnunet-scheme] 05/08: dht/client: Rewrite <datum> in terms of cisw., gnunet, 2023/02/09