README 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ;; TODO: this isn't a proper README at all!
  2. ;; TODO: guix package definition
  3. ;; SPDX-FileCopyrightText: 2022 Maxime Devos <maximedevos@telenet.be>
  4. ;;
  5. ;; SPDX-License-Identifier: AGPL-3.0-or-later
  6. ;; This module provides an interface to the GNUnet DHT service for storing and
  7. ;; retrieving blocks. This can be used to store blocks of ERIS encoded content.
  8. ;; TODO: the FS service has some fanciness w.r.t. reputation and not storing
  9. ;; everything on DHT directly, instead contacting relevant peers with CADET.
  10. ;;
  11. ;; Scheme-GNUnet is AGPL, so this module is AGPL (and not GPL) too.
  12. (use-modules (eris) (eris blocks gnunet-dht) (rnrs io ports)
  13. (fibers) (fibers conditions))
  14. (define (test)
  15. (define config (load-configuration))
  16. (define (connected)
  17. (pk 'haai))
  18. (parameterize ((eris-gnunet-dht-server
  19. (connect config #:connected connected)))
  20. ;; Put something into the DHT
  21. (define eris-urn
  22. (eris-encode "Hello world!" #:block-reducer
  23. eris-blocks-gnunet-dht-reducer))
  24. ;; Retrieve it
  25. ;; XXX: "Attempt to suspend fiber within continuation barrier"
  26. ;; --> offload to a separate thread
  27. ;;
  28. ;; Long term, it would be nice if make-custom-binary-input-port
  29. ;; and friends didn't have this problem ...
  30. (define decoded)
  31. (define done-decoding (make-condition))
  32. ((@ (ice-9 threads) call-with-new-thread)
  33. (lambda ()
  34. (set! decoded
  35. (eris-decode->bytevector eris-urn
  36. #:block-ref eris-blocks-gnunet-dht-ref))
  37. (signal-condition! done-decoding)))
  38. (wait done-decoding)
  39. (pk 'decoded (utf8->string decoded))))
  40. (export test)
  41. (run-fibers test)