From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AKfDCGxh+mFzjAAAgWs5BA (envelope-from ) for ; Wed, 02 Feb 2022 11:48:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id EOE6Bmxh+mHgBwAA9RJhRA (envelope-from ) for ; Wed, 02 Feb 2022 11:48:12 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C81E528603 for ; Wed, 2 Feb 2022 11:48:11 +0100 (CET) Received: from localhost ([::1]:38612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nFDBJ-0002tc-0e for larch@yhetil.org; Wed, 02 Feb 2022 05:48:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nFD0n-0004vO-K7 for guix-patches@gnu.org; Wed, 02 Feb 2022 05:37:20 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:57640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nFD0X-0001Q8-OI for guix-patches@gnu.org; Wed, 02 Feb 2022 05:37:14 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nFD0X-0000ob-NR for guix-patches@gnu.org; Wed, 02 Feb 2022 05:37:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52555] [RFC PATCH v2 3/5] Add (guix eris). Resent-From: pukkamustard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 02 Feb 2022 10:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52555 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxime Devos Cc: ~pukkamustard/eris@lists.sr.ht, 52555@debbugs.gnu.org Received: via spool by 52555-submit@debbugs.gnu.org id=B52555.16437982163121 (code B ref 52555); Wed, 02 Feb 2022 10:37:01 +0000 Received: (at 52555) by debbugs.gnu.org; 2 Feb 2022 10:36:56 +0000 Received: from localhost ([127.0.0.1]:51537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nFD0S-0000oH-91 for submit@debbugs.gnu.org; Wed, 02 Feb 2022 05:36:56 -0500 Received: from mout02.posteo.de ([185.67.36.66]:42363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nFD0Q-0000o2-L3 for 52555@debbugs.gnu.org; Wed, 02 Feb 2022 05:36:55 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 56048240104 for <52555@debbugs.gnu.org>; Wed, 2 Feb 2022 11:36:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1643798208; bh=QdYp9eTScxciOIUsbmQH0IFCxYyIGa4dEgifTI4NgjI=; h=From:To:Cc:Subject:Date:From; b=nE9f8POhH4rim3g8leJroMQjVo291+DN3Tz3cl5Eg03pWq7nAfb+j2q9hHesm71pb kz4MEughIDred5LHEfUBWBuUKl4ZtZkvGZYq4Va2UNojKtvJ/T/bLaG0QvR0xKX5lx 47aRfMefBC3Kup7xnWVV74R1T5YSON+Mia6J5qGOsKdD7E2GHNoeVtck6BHV5DvREc w4318Xvskg7PXn0MLTzV2jHl59LQaP+GtBzpFj0e+4Zie8AWuz/xk1xTQG4/XNHHcm GLLmIh4nPJLnwXKFo31qChIoUT51nk68YOtm2hOR7CMK3qtdbBT9D7K5JDj72Fzoau 3U1dZhCXcHb9A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JpdWz1gvwz9rxX; Wed, 2 Feb 2022 11:36:46 +0100 (CET) References: <20220125192201.7582-1-pukkamustard@posteo.net> <20220125192201.7582-4-pukkamustard@posteo.net> <0b977ae15a49b051c04922d234149a8e4762404f.camel@telenet.be> From: pukkamustard Date: Wed, 02 Feb 2022 10:28:18 +0000 In-reply-to: <0b977ae15a49b051c04922d234149a8e4762404f.camel@telenet.be> Message-ID: <86sft1h7wh.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643798891; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=+CRwAq6YT/wyAFS949P0KfQcENaDUiEp8igGLj1tySk=; b=YjcKQa1nN7LIQ1ETnkoJs/c2foqF0lGBGHIAmEfpwybJvEKYAASJkv26itJxlVgUjV0pu7 2xUZkqiA+fqCitcWMcBuz0CQKBDAxnJcx1ElDHu/+FIrLO5JcrPgdq1B0vdSSRAkbNOI0k PCEM02IwjjyhYiqq01mAnjIQ1S3K+1kD0l8Dj7DIuektT8Tz+lGCEtIrvkBuLLSfIdpxi6 1TCwPRx1pS7uG6aKvt/QYkRlEOt9E7uOGFnTQvU7xe9p7Z2hPHrlmSDRwd4r6h/Xqr7KJO ncOCwHi+t/fRPLmrkjUrneWt9fHJi98zeEkzoXuX5ifbMO0u3I12weUpWhMejw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643798891; a=rsa-sha256; cv=none; b=BlaT4PUub5o9w99h3i+wi5wCW4i2377YEP2pWN2iSCebaWRofTc+toZBaidrp//PaVp+iy 4/mI4luvfetx24P6mVRvOS9Qr584cLKtJQ767fMqRueUsamXwBacYAJVBWDoX7XvJVDYis BK26JxCrZSHrZK8UN/l/7+Jb8t3nnUNM7tcbAT06KcQtVoTG4CzhjQKIaYYxyeRP5512SD rOmPfsX7XLhPdD0a6VzvfMHqMwg0Gyk7oSuqkwr2hVJdSGLKJbjyFhFVW+9wPf+CFLBUHX Yjj/08BfNmMEH92qANep1kvc96JmmrPGwcYkgJWsK1OU2vl0iJggSc4vC4tZgQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=nE9f8POh; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.23 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=nE9f8POh; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: C81E528603 X-Spam-Score: -2.23 X-Migadu-Scanner: scn1.migadu.com X-TUID: 9EXqyhC0zEGD Maxime Devos writes: > pukkamustard schreef op di 25-01-2022 om 19:21 [+0000]: >> +(define (ipfs-daemon-alive?) >> +=C2=A0 "Attempt to connect to the IPFS daemon. Returns #t if the daemon= is alive >> +and #f else." >> +=C2=A0 (with-exception-handler >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (const #f) >> +=C2=A0=C2=A0=C2=A0 (lambda _ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let ((response _ >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (http-post (strin= g-append (%ipfs-base-url) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "/api/v0/ve= rsion")))) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (equal? 200 (response-code r= esponse)))) >> +=C2=A0=C2=A0=C2=A0 #:unwind? #t)) > > This should preferably only be catching exceptions indicating that > the daemon is down (exceptions indicating 404s, or system-errors > indicating network errors, ...). Yes, I guess it could be checked a bit finer. But at the end if an exception happens then the IPFS daemon is probably not reachable, right? If we don't care about the reason why it is not reachable then why bother with catching finer grained exceptions? >> + >> +(define guix-eris-block-reducer >> +=C2=A0 (case-lambda >> + >> +=C2=A0=C2=A0=C2=A0 ;; Check if IPFS Daemon is running. >> +=C2=A0=C2=A0=C2=A0 (() (if (ipfs-daemon-alive?) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (eri= s-blocks-ipfs-reducer) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #f)) >> + >> +=C2=A0=C2=A0=C2=A0 ;; Completion. Nothing to do. >> +=C2=A0=C2=A0=C2=A0 ((_) #t) >> + >> +=C2=A0=C2=A0=C2=A0 ((ipfs ref-block) >> +=C2=A0=C2=A0=C2=A0=C2=A0 ;; If IPFS has been initialized store block th= ere >> +=C2=A0=C2=A0=C2=A0=C2=A0 (if ipfs >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (eris-blocks-ipfs-redu= cer ipfs ref-block) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ipfs)))) > > This (ipfs-daemon-alive?) seems racy, although it's probably not. > Can we do > > (define guix-eris-block-reducer > (case-lambda > (() (guard (c (oops-it-fails-because-the-daemon-cannot-be- > contacted? c) > #false) > (eris-block-ipfs-reducer)) > [...])) > > instead? (I don't think this will work as-is, because from the name and > thunkiness, it would appear that eris-block-ipfs-reducer returns a > procedure ... Yes, eris-block-ipfs-reducer returns and SRFI-171 reducer. This is a 3-arity procedure that is either initialized, called with a block to reduce and finalized. The #f that the initialization case returns (0-arity call) is the state of the reducer. In the block reducing case (2-ary call) the state (the ipfs variable) is checked if ipfs is alive. If not the blocks are just forgotten. So guix-eris-block-reducer always returns a SRF-171 reducer, regardless of if IPFS is alive or not. This is important as the ERIS URN can still be computed without the IPFS daemon running. -pukkamustard