diff options
author | Maxime Devos <maximedevos@telenet.be> | 2021-02-17 21:03:47 +0100 |
---|---|---|
committer | Maxime Devos <maximedevos@telenet.be> | 2021-09-21 12:08:35 +0200 |
commit | 6d35e88e79d42de2f02ce77554bda1d14e513127 (patch) | |
tree | 43c066034e929b8516f95cb7d89f90b9418ea106 /gnu/gnunet/nse | |
parent | 66286858b7f677bf6cdfcd97be5b02e322842013 (diff) | |
download | gnunet-scheme-6d35e88e79d42de2f02ce77554bda1d14e513127.tar.gz gnunet-scheme-6d35e88e79d42de2f02ce77554bda1d14e513127.zip |
Implement self-documenting ‘network structures’
In contrast to scheme-bytestructures and
(gnu gnunet utils netstruct), this allows associating
a synopsis, a documention string (docstring) and arbitrary
properties with structures and fields.
Code compilation should be faster now as well and the
compiled '.go' should be smaller due to less excessive
use of syntax-rules.
TODO: update old modules
* Makefile.am (modules): compile new modules
gnu/gnunet/netstruct/procedural.scm and
gnu/gnunet/netstruct/syntactic.scm.
* README.org (Network Structures): document new modules.
* gnu/gnunet/crypto/struct.scm: use new module.
* gnu/gnunet/hashcode/struct.scm: likewise.
* gnu/gnunet/nse/struct.scm: likewise.
* gnu/gnunet/util/struct.scm: likewise.
* gnu/gnunet/netstruct/procedural.scm: new module
for defining and using network structures
procedurally.
* gnu/gnunet/netstruct/syntactic.scm: likewise,
but syntactically and with some inlining.
Diffstat (limited to 'gnu/gnunet/nse')
-rw-r--r-- | gnu/gnunet/nse/struct.scm | 93 |
1 files changed, 51 insertions, 42 deletions
diff --git a/gnu/gnunet/nse/struct.scm b/gnu/gnunet/nse/struct.scm index 7ecd8c9..53f789d 100644 --- a/gnu/gnunet/nse/struct.scm +++ b/gnu/gnunet/nse/struct.scm | |||
@@ -26,49 +26,58 @@ | |||
26 | (define-library (gnu gnunet nse struct (0 0)) | 26 | (define-library (gnu gnunet nse struct (0 0)) |
27 | (export /:msg:nse:estimate | 27 | (export /:msg:nse:estimate |
28 | /:msg:nse:flood) | 28 | /:msg:nse:flood) |
29 | (import (only (rnrs base) | 29 | (import (only (rnrs base) begin quote) |
30 | define-syntax begin) | 30 | (only (gnu gnunet util struct) |
31 | (gnu gnunet utils netstruct) | 31 | /:message-header) |
32 | (gnu gnunet hashcode struct) | 32 | (only (gnu gnunet crypto struct) |
33 | (gnu gnunet util struct)) | 33 | /peer-identity /eddsa-signature) |
34 | (only (gnu gnunet netstruct syntactic) | ||
35 | define-type structure/packed) | ||
36 | (only (gnu gnunet netstruct procedural) | ||
37 | u32/big u64/big)) | ||
34 | (begin | 38 | (begin |
35 | ;; Network size estimate sent from the service | 39 | ;; XXX check for mistakes |
36 | ;; to clients. Contains the current size estimate | ||
37 | ;; (or 0 if none has been calculated) and the | ||
38 | ;; standard deviation of known estimates. | ||
39 | (define-syntax /:msg:nse:estimate | ||
40 | (structure/packed | ||
41 | ;; Type: msg:nse:estimate | ||
42 | ("header" /message-header) | ||
43 | ("reserved" u32/big) | ||
44 | ("timestamp" /time-absolute) | ||
45 | ("size-estimate" ieee-double/big) | ||
46 | ("std-deviation" ieee-double/big))) | ||
47 | 40 | ||
48 | ;; Network size estimate reply; sent when "this" | 41 | (define-type /:msg:nse:estimate |
49 | ;; peer's timer has run out before receiving a | ||
50 | ;; valid reply from another peer. | ||
51 | (define-syntax /:msg:nse:flood | ||
52 | (structure/packed | 42 | (structure/packed |
53 | ;; Type: msg:nse:flood | 43 | (synopsis "Network size estimate sent from the service to clients") |
54 | ("header" /message-header) | 44 | (documentation |
55 | ;; Number of hops this message has taken so far. | 45 | "Contains the current size estimate |
56 | ("hop-count" u32/big) | 46 | (or 0 if none has been calculated) and the |
57 | ;; Purpose. | 47 | standard deviation of known estimates.") |
58 | ("purpose" /ecc-signature-purpose) | 48 | (properties '((message-symbol msg:nse:estimate))) |
59 | ;; The current timestamp value (which all | 49 | (field (header /:message-header)) |
60 | ;; peers should agree on). | 50 | (field (reserved u32/big)) |
61 | ("timestamp" /time-absolute) | 51 | (field (timestamp /time-absolute)) |
62 | ;; Number of matching bits between the hash | 52 | (field (size-estimate ieee-double/big)) |
63 | ;; of timestamp and the initiator's public | 53 | (field (std-deviation ieee-double/big)))) |
64 | ;; key. | ||
65 | ;; XXX add to (gnu gnunet util struct) | ||
66 | ("matching-bits" u32/big) | ||
67 | ;; Public key of the originator. | ||
68 | ("origin" /peer-identity) | ||
69 | ;; Proof of work, causing leading zeros when hashed with pkey. | ||
70 | ("proof-of-work" u64/big) | ||
71 | ;; Signature (over range specified in purpose). | ||
72 | ("signature" /eddsa-signature))))) | ||
73 | 54 | ||
74 | 55 | (define-type /:msg:nse:flood | |
56 | (structure/packed | ||
57 | (synopsis "Network size estimate reply") | ||
58 | (documentation | ||
59 | "Sent when \"this\" peer's timer has run out before receiving a | ||
60 | valid reply from another peer.") | ||
61 | (properties '((message-symbol msg:nse:flood))) | ||
62 | (field (header /:message-header)) | ||
63 | (field (hop-count u32/big) | ||
64 | (synopsis | ||
65 | "Number of hops this message has taken so far")) | ||
66 | (field (purpose /ecc-signature-purpose) | ||
67 | (synopsis "Purpose")) | ||
68 | (field (timestamp /time-absolute) | ||
69 | (synopsis "The current timestamp value (which all | ||
70 | peers should agree on)")) | ||
71 | (field (matching-bits u32/big) | ||
72 | ;; XXX add to (gnu gnunet util struct) | ||
73 | ;; XXX I don't understand the above XXX anymore | ||
74 | (synopsis | ||
75 | "Number of matching bits between the hash | ||
76 | of timestamp and the initiator's public key.")) | ||
77 | (field (origin /peer-identity) | ||
78 | (synopsis "Public key of the originator")) | ||
79 | (field (proof-of-work u64/big) | ||
80 | (synopsis | ||
81 | "Proof of work, causing leading zeros when hashed with pkey.")) | ||
82 | (field (signature /eddsa-signature) | ||
83 | (synopsis "Signature (over range specified in purpose).")))))) | ||