Skip to content

Commit

Permalink
feat: manual check for content on our Frisbii (#94)
Browse files Browse the repository at this point in the history
* feat: manual check for content on our Frisbii
* refactor: move cid & minerId to a task object

---------

Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
  • Loading branch information
bajtos authored Sep 13, 2024
1 parent d103cc5 commit 0082af5
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions manual-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@
//

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 = 'bafybeiepi56qxfcwqgpstg25r6sonig7y3pzd37lwambzmlcmbnujjri4a'
const minerId = 'f010479'
const task = {
cid: 'bafkreih25dih6ug3xtj73vswccw423b56ilrwmnos4cbwhrceudopdp5sq',
minerId: 'f0frisbii'
}

const getMinerPeerId = (minerId) =>
minerId === 'f0frisbii'
? '12D3KooWC8gXxg9LoJ9h3hy3jzBkEAxamyHEQJKtRmAuBuvoMzpr'
: defaultGetMinerPeerId(minerId)

// Run the check
const spark = new Spark()
const stats = { cid, minerId, indexerResult: null, statusCode: null, byteLength: 0 }
await spark.executeRetrievalCheck({ cid, minerId }, stats)
const spark = new Spark({ getMinerPeerId })
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 @@ -23,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 @@ -38,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 0082af5

Please sign in to comment.