Skip to content

Commit 0082af5

Browse files
authored
feat: manual check for content on our Frisbii (#94)
* feat: manual check for content on our Frisbii * refactor: move cid & minerId to a task object --------- Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
1 parent d103cc5 commit 0082af5

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

manual-check.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
//
55

66
import Spark, { getRetrievalUrl } from './lib/spark.js'
7+
import { getMinerPeerId as defaultGetMinerPeerId } from './lib/miner-info.js'
78

89
// The task to check, replace with your own values
9-
const cid = 'bafybeiepi56qxfcwqgpstg25r6sonig7y3pzd37lwambzmlcmbnujjri4a'
10-
const minerId = 'f010479'
10+
const task = {
11+
cid: 'bafkreih25dih6ug3xtj73vswccw423b56ilrwmnos4cbwhrceudopdp5sq',
12+
minerId: 'f0frisbii'
13+
}
14+
15+
const getMinerPeerId = (minerId) =>
16+
minerId === 'f0frisbii'
17+
? '12D3KooWC8gXxg9LoJ9h3hy3jzBkEAxamyHEQJKtRmAuBuvoMzpr'
18+
: defaultGetMinerPeerId(minerId)
1119

1220
// Run the check
13-
const spark = new Spark()
14-
const stats = { cid, minerId, indexerResult: null, statusCode: null, byteLength: 0 }
15-
await spark.executeRetrievalCheck({ cid, minerId }, stats)
21+
const spark = new Spark({ getMinerPeerId })
22+
const stats = { ...task, indexerResult: null, statusCode: null, byteLength: 0 }
23+
await spark.executeRetrievalCheck(task, stats)
1624
console.log('Measurement: %o', stats)
1725

1826
if (stats.providerAddress && stats.statusCode !== 200) {
@@ -23,13 +31,13 @@ if (stats.providerAddress && stats.statusCode !== 200) {
2331
console.log(
2432
' lassie fetch -o /dev/null -vv --dag-scope block --protocols graphsync --providers %s %s',
2533
JSON.stringify(stats.providerAddress),
26-
cid
34+
task.cid
2735
)
2836
console.log('\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation')
2937
break
3038
case 'http':
3139
try {
32-
const url = getRetrievalUrl(stats.protocol, stats.providerAddress, cid)
40+
const url = getRetrievalUrl(stats.protocol, stats.providerAddress, task.cid)
3341
console.log('You can get more details by requesting the following URL yourself:\n')
3442
console.log(' %s', url)
3543
console.log('\nE.g. using `curl`:')
@@ -38,7 +46,7 @@ if (stats.providerAddress && stats.statusCode !== 200) {
3846
console.log(
3947
' lassie fetch -o /dev/null -vv --dag-scope block --protocols http --providers %s %s',
4048
JSON.stringify(stats.providerAddress),
41-
cid
49+
task.cid
4250
)
4351
console.log('\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation')
4452
} catch (err) {

0 commit comments

Comments
 (0)