Skip to content
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

Proof of concept: parse head advertisement #1

Closed
wants to merge 2 commits into from
Closed

Proof of concept: parse head advertisement #1

wants to merge 2 commits into from

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Jul 2, 2024

  • Ask cid.contact for the head advertisement of the given provider
  • Fetch the head advertisement from the provider
  • Fetch the first block of entries from the provider
  • Extract the first entry (multihash)
  • Convert the multi hash to a CID v1 using the codec raw (0x55)
  • Parse PieceCID from the Graphsync metadata

Look at the file poc.js, the rest are utilities & helpers.

Links:

Signed-off-by: Miroslav Bajtoš <[email protected]>
@bajtos bajtos requested a review from juliangruber July 2, 2024 13:05
@juliangruber
Copy link
Member

What's not possible: convert the multihash to CID. We don't know what is the
multicodec of the payload.

Could we iterate over a list of known multicodecs?

Copy link
Member

@juliangruber juliangruber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I'm familiar with the concepts, lgtm!

Signed-off-by: Miroslav Bajtoš <[email protected]>
@bajtos
Copy link
Member Author

bajtos commented Jul 3, 2024

What's not possible: convert the multihash to CID. We don't know what is the
multicodec of the payload.

Could we iterate over a list of known multicodecs?

I discussed this with @willscott. It's safe always to use the raw codec. Even if the actual payload was uploaded under a CID using a different codec (typically dag-pb), both Boost and Frisbii respond with block data when the retrieval client uses raw-codec CID in the request.

I pushed a new commit adding two more steps to the PoC script:

  • Convert the multi hash to a CID v1 using the codec raw (0x55)
  • Parse PieceCID from the Graphsync metadata

Example output:

PieceCID   CID(baga6ea4seaqitygl5p5fxrbqiatnowox2zwly2dvgrhpxha4lmlqplfanvjp4mq)
PayloadCID CID(bafk2bzaceaybhh2uenrbiuv4x6xywbv6oxizamydggd5r2xgnnvr53uwnjqea)

@bajtos
Copy link
Member Author

bajtos commented Sep 10, 2024

Closing in favour of #7

@juliangruber
Copy link
Member

Closing as in #1 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants