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

dag-pb implementation of new interface? #28

Closed
carsonfarmer opened this issue Aug 2, 2020 · 6 comments
Closed

dag-pb implementation of new interface? #28

carsonfarmer opened this issue Aug 2, 2020 · 6 comments

Comments

@carsonfarmer
Copy link
Contributor

carsonfarmer commented Aug 2, 2020

It seems like this is sufficient to make it compatible (works in my tests locally). Is there a more "official" package already available (for compatibility reasons)?

const multiformats = require("multiformats/basics.js");
const { Buffer } = require("buffer");
const { util: { serialize, deserialize } } = require("ipld-dag-pb");
const dagpb = {
  encode: serialize,
  decode: buffer => deserialize(Buffer.from(buffer)),
  code: 0x70,
  name: "dag-pb",
};
multiformats.multicodec.add(dagpb);
@carsonfarmer
Copy link
Contributor Author

Note I updated the above to include the Buffer.from wrapping, which was causing errors in some cases where the Block API returns a Uint8Array (because ipld-dag-pb has a check for isBuffer).

@achingbrain
Copy link
Member

achingbrain commented Aug 4, 2020

ipld-dag-pb is having buffers removed so hopefully that won't be necessary shortly: ipld/js-ipld-dag-pb#187

@carsonfarmer
Copy link
Contributor Author

carsonfarmer commented Aug 4, 2020

Cool! Would it make sense to just add the above (once your PR lands and the CID dep is updated) as a new/additional export from the js-ipld-dag-pb library and call it a day?

@mikeal
Copy link
Contributor

mikeal commented Aug 4, 2020

if we get the other changes in to cids for the upcoming release we should be able to produce a library that easily works on both. if not, we can migrate this to the new interface and expose a js-ipld-interface compatible endpoint using the legacy function of js-multiformats.

@carsonfarmer
Copy link
Contributor Author

What is the status on this work... is the legacy approach the best one here?

@rvagg
Copy link
Member

rvagg commented Dec 31, 2020

https://github.com/ipld/js-dag-pb, solid and strict and has a matching Go friend now https://github.com/ipld/go-codec-dagpb

@rvagg rvagg closed this as completed Dec 31, 2020
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

No branches or pull requests

4 participants