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

Multidecoder Interface #195

Open
misterupkeep opened this issue Aug 23, 2022 · 3 comments
Open

Multidecoder Interface #195

misterupkeep opened this issue Aug 23, 2022 · 3 comments
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue P2 Medium: Good to have, but can wait until someone steps up

Comments

@misterupkeep
Copy link

Right now -- I should say, from how I understand it -- js-multiformats defines an interface for encoding and decoding using individual codecs. This encapsulates the codec pattern perfectly well. In fact, for encoding, it's really all you need; seeing as you can only encode something using a single codec.

However, when dealing with IPLD in the more general sense (which strives to be polymorphic over its serializations), developers are left on their own to create codec/hash registries that will hopefully be complete enough to be able to deserialize what's given to them.

This is especially exacerbated in the case of libraries which take CIDs from their users. Library authors have to either:

  • Include as many codecs as possible
    • This introduces massive dependency size overhead
    • Future needs for codecs means library updates are necessary
  • Accept extra codecs to be matched against when deserializing data

Obviously, the former of the two is an obvious antipattern. The latter, though, has been used successfully in many of the higher level JavaScript IPFS libraries to provide generic interfaces libraries can consume -- dependency injection.

I propose a similar interface, named something like a PolyMultidecoder which exposes an add() and remove() to (de)register BlockDecoders, and a single decode() which resolves and uses the correct decoder, or throws an error if it's otherwise missing.

@misterupkeep
Copy link
Author

I've written a stopgap library that exports this exact interface, which you can find here

@achingbrain
Copy link
Member

Related: #141

@rvagg
Copy link
Member

rvagg commented Sep 27, 2022

And even further back: #38

This needs to get finished, it keeps on coming up. Someone just needs to iterate on what's been attempted and discussed already and make a new PR to make new progress.

@rvagg rvagg added exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue labels Sep 27, 2022
@BigLep BigLep added the P2 Medium: Good to have, but can wait until someone steps up label Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue P2 Medium: Good to have, but can wait until someone steps up
Projects
None yet
Development

No branches or pull requests

4 participants