Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Multicodec constants #72

Closed
wants to merge 2 commits into from
Closed

Multicodec constants #72

wants to merge 2 commits into from

Conversation

vmx
Copy link
Member

@vmx vmx commented Jan 23, 2019

The codec used to be defined as string. Now you can use the numbers as
defined per multicodec constants. The codec is stored in a field
called code.

Ideally we would store it in codec, but for backwards compatibility
reasons that one will still return the name of the codec as a string.

New code should use code instead of codec to check for the codec
a CID is using.

This change needs multiformats/js-multicodec#35 to be merged first.

vmx added 2 commits January 10, 2019 22:54
Make the code more uniform, hence easier to understand.
The codec used to be defined as string. Now you can use the numbers as
defined per multicodec constants. The codec is stored in a field
called `code`.

Ideally we would store it in `codec`, but for backwards compatibility
reasons that one will still return the name of the codec as a string.

New code should use `code` instead of `codec` to check for the codec
a CID is using.
@ghost ghost assigned vmx Jan 23, 2019
@ghost ghost added the status/in-progress In progress label Jan 23, 2019
@achingbrain
Copy link
Member

FWIW, I vastly prefer the DX of using strings rather than numbers.

@vmx
Copy link
Member Author

vmx commented Jan 24, 2019

@achingbrain From the DX it's is string vs. constants.

@achingbrain
Copy link
Member

Yes, but the constants are numbers, which opens the door to new CID(1, 7, mh) as @alanshaw points out.

@vmx
Copy link
Member Author

vmx commented Jan 24, 2019

which opens the door to new CID(1, 7, mh)

Which is the whole point in order to make custom IPLD Formats easier to add (writing down why I want this is on my TODO list).

@vmx
Copy link
Member Author

vmx commented Jun 16, 2020

This effort is superseded by https://github.com/multiformats/js-multiformats, which does exactly that. Thanks @mikeal for picking up that idea.

@vmx vmx closed this Jun 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants