Skip to content

Commit

Permalink
feat(deps): update to new blob-fetcher (#150)
Browse files Browse the repository at this point in the history
# Goals

Use the new refactor freeway

# Implementation

- update dependencies for blob-fetcher & indexing-service-client
- update withLocator to use new initializations
- change on the factories for location claims in the tests -- this is
weird cause normally I'd say tests breaking is a bad sign, but this
certianly appears to be a genuine bug in the factor that was covered up
by a potential bug in the old code (always using digest as the location
claim's key even if content in the actual claim was different)
  • Loading branch information
hannahhoward authored Feb 5, 2025
1 parent 0ce5f5d commit 87e3298
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 81 deletions.
108 changes: 40 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
"@microlabs/otel-cf-workers": "^1.0.0-rc.48",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/sdk-trace-base": "^1.27.0",
"@storacha/indexing-service-client": "^2.0.0",
"@storacha/indexing-service-client": "^2.1.0",
"@ucanto/client": "^9.0.1",
"@ucanto/principal": "^9.0.1",
"@ucanto/transport": "^9.1.1",
"@web3-storage/blob-fetcher": "^2.5.0",
"@web3-storage/blob-fetcher": "^3.0.0",
"@web3-storage/capabilities": "^17.4.1",
"@web3-storage/gateway-lib": "^5.1.2",
"dagula": "^8.0.0",
Expand Down
19 changes: 9 additions & 10 deletions src/middleware/withLocator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ContentClaimsLocator from '@web3-storage/blob-fetcher/locator/content-claims'
import { IndexingServiceLocator } from '@web3-storage/blob-fetcher/locator/indexing-service'
import { ContentClaimsClient } from '@web3-storage/blob-fetcher/locator/content-claims-client'
import * as Locator from '@web3-storage/blob-fetcher/locator'
import { Client } from '@storacha/indexing-service-client'

/**
Expand All @@ -23,15 +23,13 @@ export function withLocator (handler) {
return async (request, env, ctx) => {
const useIndexingService = isIndexingServiceEnabled(request, env)

const locator = useIndexingService
? new IndexingServiceLocator({
client: new Client({
serviceURL: env.INDEXING_SERVICE_URL
? new URL(env.INDEXING_SERVICE_URL)
: undefined
})
const client = useIndexingService
? new Client({
serviceURL: env.INDEXING_SERVICE_URL
? new URL(env.INDEXING_SERVICE_URL)
: undefined
})
: ContentClaimsLocator.create({
: new ContentClaimsClient({
serviceURL: env.CONTENT_CLAIMS_SERVICE_URL
? new URL(env.CONTENT_CLAIMS_SERVICE_URL)
: undefined,
Expand All @@ -41,6 +39,7 @@ export function withLocator (handler) {
: undefined
})

const locator = Locator.create({ client })
return handler(request, env, { ...ctx, locator })
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/content-claims.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const generateBlockLocationClaims = async (signer, shard, carStream, loca
.pipeTo(new WritableStream({
async write ({ cid, blockOffset, blockLength }) {
const blocks = claims.get(cid) ?? []
blocks.push(await generateLocationClaim(signer, shard, location, blockOffset, blockLength))
blocks.push(await generateLocationClaim(signer, cid, location, blockOffset, blockLength))
claims.set(cid, blocks)
}
}))
Expand Down

0 comments on commit 87e3298

Please sign in to comment.