Skip to content

Commit 3f8fc20

Browse files
committed
refactor: move cid & minerId to a task object
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
1 parent 8cb9c92 commit 3f8fc20

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

manual-check.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import Spark, { getRetrievalUrl } from './lib/spark.js'
77
import { getMinerPeerId as defaultGetMinerPeerId } from './lib/miner-info.js'
88

99
// The task to check, replace with your own values
10-
const cid = 'bafkreih25dih6ug3xtj73vswccw423b56ilrwmnos4cbwhrceudopdp5sq'
11-
const minerId = 'f0frisbii'
10+
const task = {
11+
cid: 'bafkreih25dih6ug3xtj73vswccw423b56ilrwmnos4cbwhrceudopdp5sq',
12+
minerId: 'f0frisbii'
13+
}
1214

1315
const getMinerPeerId = (minerId) =>
1416
minerId === 'f0frisbii'
@@ -17,8 +19,8 @@ const getMinerPeerId = (minerId) =>
1719

1820
// Run the check
1921
const spark = new Spark({ getMinerPeerId })
20-
const stats = { cid, minerId, indexerResult: null, statusCode: null, byteLength: 0 }
21-
await spark.executeRetrievalCheck({ cid, minerId }, stats)
22+
const stats = { ...task, indexerResult: null, statusCode: null, byteLength: 0 }
23+
await spark.executeRetrievalCheck(task, stats)
2224
console.log('Measurement: %o', stats)
2325

2426
if (stats.providerAddress && stats.statusCode !== 200) {
@@ -29,13 +31,13 @@ if (stats.providerAddress && stats.statusCode !== 200) {
2931
console.log(
3032
' lassie fetch -o /dev/null -vv --dag-scope block --protocols graphsync --providers %s %s',
3133
JSON.stringify(stats.providerAddress),
32-
cid
34+
task.cid
3335
)
3436
console.log('\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation')
3537
break
3638
case 'http':
3739
try {
38-
const url = getRetrievalUrl(stats.protocol, stats.providerAddress, cid)
40+
const url = getRetrievalUrl(stats.protocol, stats.providerAddress, task.cid)
3941
console.log('You can get more details by requesting the following URL yourself:\n')
4042
console.log(' %s', url)
4143
console.log('\nE.g. using `curl`:')
@@ -44,7 +46,7 @@ if (stats.providerAddress && stats.statusCode !== 200) {
4446
console.log(
4547
' lassie fetch -o /dev/null -vv --dag-scope block --protocols http --providers %s %s',
4648
JSON.stringify(stats.providerAddress),
47-
cid
49+
task.cid
4850
)
4951
console.log('\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation')
5052
} catch (err) {

0 commit comments

Comments
 (0)