4
4
//
5
5
6
6
import Spark , { getRetrievalUrl } from './lib/spark.js'
7
+ import { getMinerPeerId as defaultGetMinerPeerId } from './lib/miner-info.js'
7
8
8
9
// 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 )
11
19
12
20
// 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 )
16
24
console . log ( 'Measurement: %o' , stats )
17
25
18
26
if ( stats . providerAddress && stats . statusCode !== 200 ) {
@@ -23,13 +31,13 @@ if (stats.providerAddress && stats.statusCode !== 200) {
23
31
console . log (
24
32
' lassie fetch -o /dev/null -vv --dag-scope block --protocols graphsync --providers %s %s' ,
25
33
JSON . stringify ( stats . providerAddress ) ,
26
- cid
34
+ task . cid
27
35
)
28
36
console . log ( '\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation' )
29
37
break
30
38
case 'http' :
31
39
try {
32
- const url = getRetrievalUrl ( stats . protocol , stats . providerAddress , cid )
40
+ const url = getRetrievalUrl ( stats . protocol , stats . providerAddress , task . cid )
33
41
console . log ( 'You can get more details by requesting the following URL yourself:\n' )
34
42
console . log ( ' %s' , url )
35
43
console . log ( '\nE.g. using `curl`:' )
@@ -38,7 +46,7 @@ if (stats.providerAddress && stats.statusCode !== 200) {
38
46
console . log (
39
47
' lassie fetch -o /dev/null -vv --dag-scope block --protocols http --providers %s %s' ,
40
48
JSON . stringify ( stats . providerAddress ) ,
41
- cid
49
+ task . cid
42
50
)
43
51
console . log ( '\nHow to install Lassie: https://github.com/filecoin-project/lassie?tab=readme-ov-file#installation' )
44
52
} catch ( err ) {
0 commit comments