Skip to content

Commit

Permalink
feat: more info when manual check fails
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
  • Loading branch information
bajtos committed Aug 9, 2024
1 parent 5c7f6b3 commit cc9b8c6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions manual-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}

0 comments on commit cc9b8c6

Please sign in to comment.