[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet-scheme] 256/324: nse/client: Verify positivity of estimate.
From: |
gnunet |
Subject: |
[gnunet-scheme] 256/324: nse/client: Verify positivity of estimate. |
Date: |
Tue, 21 Sep 2021 13:24:56 +0200 |
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 4f0fe630854160aefb39cbc97f8ec756e45839fd
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Fri Sep 10 16:43:14 2021 +0200
nse/client: Verify positivity of estimate.
* gnu/gnunet/nse/client.scm
(estimate:logarithmic-number-peers,estimate:standard-deviation)
(estimate:number-peers): Remove resolved XXX.
(reconnect)[handlers]<msg:nse:estimate>{well-formed?}: Verify
'size-estimate' and 'std-deviation' fields.
---
doc/scheme-gnunet.tm | 14 ++++++++------
gnu/gnunet/nse/client.scm | 28 ++++++++++++----------------
2 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/doc/scheme-gnunet.tm b/doc/scheme-gnunet.tm
index d8b0b81..49b5a74 100644
--- a/doc/scheme-gnunet.tm
+++ b/doc/scheme-gnunet.tm
@@ -573,17 +573,20 @@
reconnecting, the idempotent procedure <scm|disconnect!> can be called on
the server object.
+ <todo|input, validation, I/O errors?>
+
The estimate object has a number of accessors:
<\explain>
<scm|(estimate:logarithmic-number-peers <var|estimate>)>
</explain|The base-2 logarithm of the number of peers (estimated), as a
- flonum>
+ positive flonum, possibly zero or infinite>
<\explain>
<scm|(estimate:number-peers <var|estimate>)>
- </explain|The number of peers (estimated), as a flonum.<space|1em>This is
- not necessarily an (inexact) <scm|integer?>, as it is only an estimate.>
+ </explain|The number of peers (estimated), as a flonum, at least <scm|1.0>
+ and possibly infinite.<space|1em>This is not necessarily an (inexact)
+ <scm|integer?>, as it is only an estimate.>
<\explain>
<scm|(estimate:timestamp estimate)>
@@ -594,15 +597,14 @@
<scm|(estimate:standard-deviation <var|estimate>)>
</explain|The estimated standard deviation on the base-2 logarithm of
peers, calculated over the last 64 rounds, with the <math|<frac|N|N-1>>
- correction.>
+ correction.<space|1em>This is a positive flonum, possibly zero or
+ infinite.>
Assuming the network size is stable and the errors on the logarithmic
estimate are normally distributed, the procedure
<scm|estimate:standard-deviation> can be used to put probablistic error
bounds on the number of peers on the network. <todo|example>
- <todo|what if the server sends bogus data (e.g. negative)>
-
<chapter|Implementation details>
TODO<appendix|GNU Free Documentation License>
diff --git a/gnu/gnunet/nse/client.scm b/gnu/gnunet/nse/client.scm
index d7a4369..1339b33 100644
--- a/gnu/gnunet/nse/client.scm
+++ b/gnu/gnunet/nse/client.scm
@@ -35,7 +35,8 @@
disconnect!
estimate)
(import (only (rnrs base)
- begin define quote lambda case values expt = else apply)
+ begin define quote lambda case values expt = else apply
+ and >=)
(only (rnrs control)
when)
(only (rnrs records syntactic)
@@ -91,27 +92,19 @@ yet, return @code{#false}."
(define (estimate:logarithmic-number-peers estimate)
"Return the logarithm (base 2) of the number of peers on the network
-in @var{estimate} as a positive (possibly zero) number. As the estimate
-is an estimate, the return value is inexact.
-
-XXX: if the server is broken, it could return a negative number, or NaN!
-Maybe +inf.0 as well?"
+in @var{estimate} as a positive flonum (possibly zero or infinite)."
(%estimate:logarithmic-number-peers estimate))
(define (estimate:standard-deviation estimate)
"Return the standard deviation of the logarithmic estimate
-of the number of peers of the last 64 rounds, as a positive, possibly
-zero flonum.
-
-XXX: if the server is broken, it could be negative!"
+of the number of peers of the last 64 rounds as a positive flonum
+(possibly zero or infinite)."
(%estimate:standard-deviation estimate))
(define (estimate:number-peers estimate)
"Return the estimate of the number of peers on the network in
-@var{estimate} as a positive flonum. It is not necessarily integral.
-
-XXX: if the server is broken, it could return a negative number, or NaN!
-Maybe +inf.0 as well?"
+@var{estimate} as a strictly-positive flonum, at least @code{1.0}
+and possibly infinite."
(expt 2.0 (estimate:logarithmic-number-peers estimate)))
(define (estimate:timestamp estimate)
@@ -143,8 +136,11 @@ even if not connected. This is an idempotent operation."
(type (symbol-value message-type msg:nse:estimate))
((interpose code) code)
((well-formed? slice)
- (= (slice-length slice)
- (sizeof /:msg:nse:estimate '())))
+ (and (= (slice-length slice)
+ (sizeof /:msg:nse:estimate '()))
+ ;; XXX: these two lines below are not tested
+ (>= (read% /:msg:nse:estimate '(size-estimate) slice) 0)
+ (>= (read% /:msg:nse:estimate '(std-deviation) slice) 0)))
((handle! slice) (handle-estimate! slice)))))
(define (send-start!)
;; The service only starts sending estimates once
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet-scheme] 242/324: nse/client: Remove unused fields., (continued)
- [gnunet-scheme] 242/324: nse/client: Remove unused fields., gnunet, 2021/09/21
- [gnunet-scheme] 243/324: doc/scheme-gnunet.tm: Correct use of 'connected' and 'updated'., gnunet, 2021/09/21
- [gnunet-scheme] 237/324: mq-impl/stream: Allow closing the queue on request., gnunet, 2021/09/21
- [gnunet-scheme] 247/324: nse/client: Only call 'send-start!' after 'mq' has been defined., gnunet, 2021/09/21
- [gnunet-scheme] 248/324: tests/mq-stream: Add missing parenthesis., gnunet, 2021/09/21
- [gnunet-scheme] 249/324: nse/client: Prepare for auto-reconnecting., gnunet, 2021/09/21
- [gnunet-scheme] 250/324: doc: Document that (gnu gnunet nse client) reconnects., gnunet, 2021/09/21
- [gnunet-scheme] 253/324: nse/client: Correct type documentation of <server>., gnunet, 2021/09/21
- [gnunet-scheme] 254/324: doc: Document how to disconnect from the NSE server., gnunet, 2021/09/21
- [gnunet-scheme] 258/324: build: Install compiled Guile modules in appropriate location., gnunet, 2021/09/21
- [gnunet-scheme] 256/324: nse/client: Verify positivity of estimate.,
gnunet <=
- [gnunet-scheme] 257/324: git: Mark .scm as Scheme files for diffing purposes., gnunet, 2021/09/21
- [gnunet-scheme] 261/324: git: Ignore some files created by Emacs., gnunet, 2021/09/21
- [gnunet-scheme] 259/324: build: Install the HTML and PDF documentation., gnunet, 2021/09/21
- [gnunet-scheme] 266/324: build: Add (gnu extractor enum) to the makefile., gnunet, 2021/09/21
- [gnunet-scheme] 255/324: nse/client: Remove resolved TODO., gnunet, 2021/09/21
- [gnunet-scheme] 264/324: build: Use $< and $@ for PDF and HTML generation., gnunet, 2021/09/21
- [gnunet-scheme] 252/324: nse/client: Allow disconnecting., gnunet, 2021/09/21
- [gnunet-scheme] 263/324: build: Introduce TEXMACS_CONVERT variable., gnunet, 2021/09/21
- [gnunet-scheme] 267/324: build: Distribute and install TeXmacs documentation., gnunet, 2021/09/21
- [gnunet-scheme] 260/324: git: Ignore generated documentation., gnunet, 2021/09/21