diff mbox series

[bug#52555,RFC,v2,4/5] publish: Add support for storing ERIS encoded blocks to IPFS.

Message ID 20220125192201.7582-5-pukkamustard@posteo.net
State New
Headers show
Series Decentralized substitute distribution with ERIS | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

pukkamustard Jan. 25, 2022, 7:22 p.m. UTC
* guix/scripts/publish.scm (bake-narinfo+nar): Use guix-eris-block-reducer
from (guix eris).
---
 guix/scripts/publish.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

M Jan. 29, 2022, 9:28 p.m. UTC | #1
pukkamustard schreef op di 25-01-2022 om 19:22 [+0000]:
> +                    (let ((eris-urn _
> +                                    (eris-encode port
> +                                                 #:block-size
> +                                                 %eris-block-size-large
> +                                                 #:block-reducer
> +                                                 guix-eris-block-reducer)))
> +                      (uri->string eris-urn))))))))

IIUC (and quite probably I don't, because I've only being reading
things cursorly), eris-encode returns #false when the IPFS daemon is
down (because then guix-eris-block-reducer returns #false).

In that case, (uri->string eris-urn) = (uri->string #false) would
throw an exception:

scheme@(guile-user)> ((@ (web uri) uri->string) #false)
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
In procedure struct-vtable: Wrong type argument in position 1
(expecting struct): #f

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In web/uri.scm:
   336:17  1 (uri->string #f #:include-fragment? _)
In ice-9/boot-9.scm:
  1669:16  0 (raise-exception _ #:continuable? _)

Greetings,
Maxime.
pukkamustard Feb. 2, 2022, 10:24 a.m. UTC | #2
Maxime Devos <maximedevos@telenet.be> writes:

> [[PGP Signed Part:Undecided]]
> pukkamustard schreef op di 25-01-2022 om 19:22 [+0000]:
>> +                    (let ((eris-urn _
>> +                                    (eris-encode port
>> +                                                 #:block-size
>> +                                                 %eris-block-size-large
>> +                                                 #:block-reducer
>> +                                                 guix-eris-block-reducer)))
>> +                      (uri->string eris-urn))))))))
>
> IIUC (and quite probably I don't, because I've only being reading
> things cursorly), eris-encode returns #false when the IPFS daemon is
> down (because then guix-eris-block-reducer returns #false).

No, eris-encode will still return the ERIS URN. The blocks will just not
be stored in IPFS if the IPFS daemon is not running. See also my
response to the questions on guix-eris-block-reducer in (guix eris).

-pukkamustard
diff mbox series

Patch

diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index 9c83f5183d..556107ab7d 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -41,6 +41,7 @@  (define-module (guix scripts publish)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-37)
+  #:use-module (srfi srfi-71)
   #:use-module (web http)
   #:use-module (web request)
   #:use-module (web response)
@@ -58,6 +59,7 @@  (define-module (guix scripts publish)
   #:use-module (guix workers)
   #:use-module (guix store)
   #:use-module ((guix serialization) #:select (write-file))
+  #:use-module (guix eris)
   #:use-module (eris)
   #:use-module (zlib)
   #:autoload   (lzlib) (call-with-lzip-output-port
@@ -644,8 +646,14 @@  (define (eris-encode-nar compressions)
                 (stat (stat nar #f)))
            (and stat
                 (call-with-input-file nar
-                  (cut eris-encode->string <>
-                       #:block-size %eris-block-size-large))))))
+                  (lambda (port)
+                    (let ((eris-urn _
+                                    (eris-encode port
+                                                 #:block-size
+                                                 %eris-block-size-large
+                                                 #:block-reducer
+                                                 guix-eris-block-reducer)))
+                      (uri->string eris-urn))))))))
 
   (let ((compression (actual-compressions item compressions)))