Skip to content

Commit

Permalink
refactor: move cid & minerId to a task object
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
  • Loading branch information
bajtos committed Sep 12, 2024
1 parent 8cb9c92 commit 3f8fc20
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions manual-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import Spark, { getRetrievalUrl } from './lib/spark.js'
import { getMinerPeerId as defaultGetMinerPeerId } from './lib/miner-info.js'

// The task to check, replace with your own values
const cid = 'bafkreih25dih6ug3xtj73vswccw423b56ilrwmnos4cbwhrceudopdp5sq'
const minerId = 'f0frisbii'
const task = {
cid: 'bafkreih25dih6ug3xtj73vswccw423b56ilrwmnos4cbwhrceudopdp5sq',
minerId: 'f0frisbii'
}

const getMinerPeerId = (minerId) =>
minerId === 'f0frisbii'
Expand All @@ -17,8 +19,8 @@ const getMinerPeerId = (minerId) =>

// Run the check
const spark = new Spark({ getMinerPeerId })
const stats = { cid, minerId, indexerResult: null, statusCode: null, byteLength: 0 }
await spark.executeRetrievalCheck({ cid, minerId }, stats)
const stats = { ...task, indexerResult: null, statusCode: null, byteLength: 0 }
await spark.executeRetrievalCheck(task, stats)
console.log('Measurement: %o', stats)

if (stats.providerAddress && stats.statusCode !== 200) {
Expand All @@ -29,13 +31,13 @@ if (stats.providerAddress && stats.statusCode !== 200) {
console.log(
' lassie fetch -o /dev/null -vv --dag-scope block --protocols graphsync --providers %s %s',
JSON.stringify(stats.providerAddress),
cid
task.cid
)
console.log('\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation')
break
case 'http':
try {
const url = getRetrievalUrl(stats.protocol, stats.providerAddress, cid)
const url = getRetrievalUrl(stats.protocol, stats.providerAddress, task.cid)
console.log('You can get more details by requesting the following URL yourself:\n')
console.log(' %s', url)
console.log('\nE.g. using `curl`:')
Expand All @@ -44,7 +46,7 @@ if (stats.providerAddress && stats.statusCode !== 200) {
console.log(
' lassie fetch -o /dev/null -vv --dag-scope block --protocols http --providers %s %s',
JSON.stringify(stats.providerAddress),
cid
task.cid
)
console.log('\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation')
} catch (err) {
Expand Down

0 comments on commit 3f8fc20

Please sign in to comment.