Skip to content

Commit

Permalink
Lassie (#5)
Browse files Browse the repository at this point in the history
* ci: upgrade zinnia

* fetch from lassie not saturn

* fix typo

* log

* increase receive timeout

* add log http error text

* add pass protocol and provider to lassie

* safely construct querystrings

* fix lint

* Update lib/spark.js

Co-authored-by: Miroslav Bajtoš <oss@bajtos.net>

---------

Co-authored-by: Miroslav Bajtoš <oss@bajtos.net>
  • Loading branch information
juliangruber and bajtos authored Jun 14, 2023
1 parent 267e1d0 commit e418913
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: curl -L https://github.com/filecoin-station/zinnia/releases/download/v0.10.0/zinnia-linux-x64.tar.gz | tar -xz
- run: curl -L https://github.com/filecoin-station/zinnia/releases/download/v0.11.0/zinnia-linux-x64.tar.gz | tar -xz
- uses: actions/setup-node@v3
- run: npx standard
- run: ./zinnia run test.js
15 changes: 11 additions & 4 deletions lib/spark.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class Spark {
}

async getRetrieval () {
console.log('Geting retrieval...')
console.log('Getting retrieval...')
const res = await this.#fetch('https://spark.fly.dev/retrievals', {
method: 'POST'
})
Expand All @@ -24,7 +24,7 @@ export default class Spark {
}

async fetchCAR (url, stats) {
console.log('Fetching CAR...')
console.log(`Fetching ${url}...`)

// Abort if no progress was made for 10 seconds
const controller = new AbortController()
Expand All @@ -34,7 +34,7 @@ export default class Spark {
if (timeout) {
clearTimeout(timeout)
}
timeout = setTimeout(() => controller.abort(), 10_000)
timeout = setTimeout(() => controller.abort(), 60_000)
}

try {
Expand All @@ -51,6 +51,9 @@ export default class Spark {
stats.byteLength += value.byteLength
resetTimeout()
}
} else {
console.error('Retrieval failed with status code %s: %s',
res.status, await res.text())
}
} finally {
clearTimeout(timeout)
Expand Down Expand Up @@ -93,7 +96,11 @@ export default class Spark {
byteLength: 0,
statusCode: null
}
const url = `https://strn.pl/ipfs/${retrieval.cid}`
const searchParams = new URLSearchParams({
protocols: retrieval.protocol,
providers: retrieval.providerAddress
})
const url = `ipfs://${retrieval.cid}?${searchParams.toString()}`
try {
await this.fetchCAR(url, stats)
success = true
Expand Down

0 comments on commit e418913

Please sign in to comment.