From cc9b8c63d76e5a0d4ffcef90f1e71326cf08eb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Fri, 9 Aug 2024 13:28:22 +0200 Subject: [PATCH] feat: more info when manual check fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- manual-check.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/manual-check.js b/manual-check.js index 17b7fd1..7de9939 100644 --- a/manual-check.js +++ b/manual-check.js @@ -3,6 +3,7 @@ // zinnia run manual-check.js // +import { multiaddrToHttpUrl } from './lib/multiaddr.js' import Spark from './lib/spark.js' // The task to check, replace with your own values @@ -14,3 +15,25 @@ const spark = new Spark() const stats = { cid, minerId, indexerResult: null, statusCode: null, byteLength: 0 } await spark.executeRetrievalCheck({ cid, minerId }, stats) console.log('Measurement: %o', stats) + +if (stats.providerAddress && stats.statusCode !== 200) { + console.log('\nThe retrieval failed.') + switch (stats.protocol) { + case 'graphsync': + console.log('You can get more details by running Lassie manually:\n') + console.log(' lassie fetch -o /dev/null -vv --dag-scope block --protocols graphsync --providers %j', stats.providerAddress) + console.log('\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation') + break + case 'http': + try { + const url = multiaddrToHttpUrl(stats.providerAddress) + console.log('You can get more details by requesting the following URL yourself:\n') + console.log(' %s', url) + console.log('\nE.g. using `curl`:') + console.log(' curl -i %j', url) + } catch (err) { + console.log('The provider address %j cannot be converted to a URL: %s', stats.providerAddress, err.message ?? err) + } + break + } +}