-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support DAG-CBOR encoded entries #119
Comments
Example advertisement from Curio: Example Entries in DAG-CBOR format: (See #117 for more details about this SP) Decoded output as produced by
Code dealing with entries in piece-indexer: piece-indexer/indexer/lib/advertisement-walker.js Lines 283 to 316 in 684bdc0
Notes:
|
Rather than relying on a string prefix, we should parse the CID string and look at the multicodec value. import { CID } from 'multiformats/cid'
const cid = CID.parse('bagu...')
switch (cid.code) {
//
} Is there any library we can use to parse payload based on CID's codec, so that we don't have to implement this ourselves? |
Inside
return await res.json() To support DAG-CBOR, we need to change this line to support other codecs. A high-level proposal: // at the top of the file
import { decode as decodeDagCbor } from '@ipld/dag-cbor'
// in `fetchCid()`
const codec = CID.parse(cid).code
switch (codec) {
case 0x0129 /* DAG-JSON */:
return await res.json()
case 0x71 /* DAG-CBOR */:
const bytes = await res.bytes()
return decodeDagCbor(bytes)
default:
throw new Error(`Unsupported CID codec ${codec}`)
} References: |
Implementation Plan for DAG-CBOR Support in Piece IndexerContextThe piece-indexer currently only processes DAG-JSON encoded entries (CIDs starting with "bagu"). However, some providers like Curio use DAG-CBOR encoding (CIDs starting with "bafy"). We need to support both formats to ensure complete indexing of all providers. Key Format Differences
Implementation Approach1. Add a new
|
The high-level plan looks good to me. 👍🏻 Re: Integration Testing is dependent on support for http-path. What plan do you propose to ensure we don't forget to implement the integration tests? |
I included the http-path implementation in the PR for this issue. Separating it into its own PR would be very tedious to test as we cannot yet decode the data that is returned even upon successfully calling the URL that stems from the http-path. The integration test will be done once this PR is merged and a new PR for the second issue for the piece indexer is created. Only then can we test the entirety of the curio functionality in the To answer your question: The integration test which tests the function |
Curio serialises advertised entries using DAG-CBOR encoding. (Boost/Venus use DAG-JSON.)
We need to improve piece-indexer to support this encoding too.
The text was updated successfully, but these errors were encountered: