Add `time-rel` to replace all ad-hoc time calculations.
This commit is contained in:
parent
ff8e19b523
commit
12e8a31b23
|
@ -75,5 +75,5 @@
|
|||
;; add a timeout in 5 seconds
|
||||
(simple-format *stderr* "scheduler add: timeout\n")
|
||||
(force-output *stderr*)
|
||||
(add-task! shutdown-task #:delay (* 5 1000 1000))))))
|
||||
(add-task! shutdown-task #:delay (time-rel #:seconds 5))))))
|
||||
(call-with-scheduler config first-task)))
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
(define (first-task _)
|
||||
(set! *handle* (start-ego-lookup *config* "testremi" print-ego))
|
||||
(set! *kill-task* (add-task! shutdown-task #:delay (* 5 1000 1000))))
|
||||
(set! *kill-task* (add-task! shutdown-task #:delay (time-rel #:seconds 5))))
|
||||
|
||||
(define (main args)
|
||||
(set! *config* (load-configuration "~/.gnunet/gnunet.conf"))
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
(define (first-task _)
|
||||
(set! *handle* (open-identity-service *config* print-ego))
|
||||
(set! *kill-task* (add-task! shutdown-task #:delay (* 5 1000 1000))))
|
||||
(set! *kill-task* (add-task! shutdown-task #:delay (time-rel #:seconds 5))))
|
||||
|
||||
(define (main args)
|
||||
(set! *config* (load-configuration "~/.gnunet/gnunet.conf"))
|
||||
|
|
|
@ -74,7 +74,7 @@ demanded ego or call IDENTITY-CONTINUATION."
|
|||
(set! *kill-task*
|
||||
(add-task! (lambda (_)
|
||||
(close-identity-service *identity-handle*))
|
||||
#:delay (* 5 1000 1000))))
|
||||
#:delay (time-rel #:seconds 5))))
|
||||
((binary file-name)
|
||||
(set! *binary-name* binary)
|
||||
(set! *filename* file-name)
|
||||
|
@ -111,7 +111,7 @@ scan on *FILENAME*."
|
|||
(set! *kill-task* (add-task! (lambda (_)
|
||||
(display "Stopping directory scan (unexpected)\n")
|
||||
(stop-directory-scan *dir-scanner*))
|
||||
#:delay (* 5 1000 1000))))
|
||||
#:delay (time-rel #:seconds 5))))
|
||||
(else
|
||||
(simple-format #t "Error: no ego named ~a has been found!\n"
|
||||
*namespace-name*)
|
||||
|
@ -145,7 +145,7 @@ start the publication by calling DIRSCAN-CONTINUATION."
|
|||
(set! *kill-task* (add-task! (lambda (_)
|
||||
(display "Stopping publication (unexpected)\n")
|
||||
(stop-publish *publish-handle*))
|
||||
#:delay (* 5 1000 1000))))
|
||||
#:delay (time-rel #:seconds 5))))
|
||||
|
||||
(define (progress-callback %info)
|
||||
"The third callback, called repeteadly by the publishing tasks once the
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
(define-module (gnunet-search)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (system foreign)
|
||||
#:use-module (gnu gnunet common)
|
||||
#:use-module (gnu gnunet configuration)
|
||||
#:use-module (gnu gnunet scheduler)
|
||||
#:use-module (gnu gnunet identity)
|
||||
|
@ -57,7 +58,7 @@
|
|||
(start-ego-lookup *config* *ns-name* ego-callback))
|
||||
(set! *kill-task*
|
||||
(add-task! (lambda (_) (stop-ego-lookup! *lookup-op*))
|
||||
#:delay (* 5 1000 1000))))
|
||||
#:delay (time-rel #:seconds 5))))
|
||||
|
||||
(define (ego-callback ego)
|
||||
(cancel-task! *kill-task*)
|
||||
|
@ -74,7 +75,7 @@
|
|||
(set! *search-handle* (start-search *fs-handle* *uri*))
|
||||
(set! *kill-task* (add-task! (lambda (_)
|
||||
(stop-search *search-handle*))
|
||||
#:delay (* 5 1000 1000)))
|
||||
#:delay (time-rel #:seconds 5)))
|
||||
(simple-format #t "Searching ~a\n" (uri->string *uri*)))))
|
||||
|
||||
(define (progress-callback %info)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
(define-module (gnunet-search)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (system foreign)
|
||||
#:use-module (gnu gnunet common)
|
||||
#:use-module (gnu gnunet container metadata)
|
||||
#:use-module (gnu gnunet fs)
|
||||
#:use-module (gnu gnunet fs uri)
|
||||
|
@ -33,10 +34,8 @@
|
|||
(define (progress-cb %info)
|
||||
(when (equal? '(#:search #:result) (progress-info-status %info))
|
||||
(match (parse-c-progress-info %info)
|
||||
(((context cctx pctx query duration anonymity
|
||||
(metadata uri result applicability-rank)) status handle)
|
||||
(match (parse-c-struct result '(* * * *)) ; incomplete parse of result
|
||||
((_ _ %uri %metadata)
|
||||
(((context _ _ query duration anonymity
|
||||
(%metadata %uri %result applicability-rank)) _ _)
|
||||
(let* ((uri (uri->string (wrap-uri %uri)))
|
||||
(meta (wrap-metadata %metadata))
|
||||
(result-directory? (is-directory? meta))
|
||||
|
@ -54,7 +53,7 @@
|
|||
uri))
|
||||
(else
|
||||
(simple-format #t "gnunet-download -o \"~a\" ~a\n"
|
||||
result-filename uri))))))))))
|
||||
result-filename uri))))))))
|
||||
|
||||
(define (main args)
|
||||
(let ((config (load-configuration config-file)))
|
||||
|
@ -65,5 +64,5 @@
|
|||
(search (start-search fs-service uri)))
|
||||
;; adds a timeout in 5 seconds
|
||||
(add-task! (lambda (_) (stop-search search))
|
||||
#:delay (* 5 1000 1000))))
|
||||
#:delay (time-rel #:seconds 5))))
|
||||
(call-with-scheduler config first-task)))
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
time-relative
|
||||
time-absolute
|
||||
time-rel
|
||||
|
||||
ecdsa-public-key
|
||||
ecdsa-public-key?
|
||||
eddsa-public-key
|
||||
|
@ -59,6 +61,14 @@
|
|||
|
||||
(define time-relative uint64)
|
||||
(define time-absolute uint64)
|
||||
|
||||
(define* (time-rel #:key (hours 0) (minutes 0) (seconds 0) (milli 0) (micro 0))
|
||||
(let* ((minutes* (+ (* hours 60) minutes))
|
||||
(seconds* (+ (* minutes* 60) seconds))
|
||||
(milli* (+ (* seconds* 1000) milli))
|
||||
(micro* (+ (* milli* 1000) micro)))
|
||||
micro*))
|
||||
|
||||
(define ecdsa-public-key (generate (/ 256 8 4) uint32))
|
||||
(define eddsa-public-key ecdsa-public-key)
|
||||
(define eddsa-signature (list eddsa-public-key
|
||||
|
|
|
@ -241,9 +241,6 @@ callback."
|
|||
;;
|
||||
;;+TODO: dynamically allocate the entire structure & client-name, so that we can
|
||||
;; call GNUNET_FS_stop on the returned handle.
|
||||
;;
|
||||
;;+TODO: replace value for avg_block_latency with a call to a function
|
||||
;; akin `(time-relative #:minutes 1)`
|
||||
(define (%fs-start %config %client-name %progress-callback)
|
||||
(make-c-struct struct-fs-handle
|
||||
(list %config
|
||||
|
@ -260,7 +257,7 @@ callback."
|
|||
%null-pointer ; probes_tail
|
||||
%null-pointer ; queue_job
|
||||
%null-pointer ; probe_ping_task
|
||||
(* 60 1000 1000) ; avg_block_latency (1 minute)
|
||||
(time-rel #:minutes 1) ; avg_block_latency
|
||||
0 ; active_downloads
|
||||
0 ; active_blocks
|
||||
0 ; flags
|
||||
|
|
Loading…
Reference in New Issue