multiformats / multiformats/multicodec

document recommendations for multicodec implementations

Open
#199 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
383
Forks
221
Avg merge
24d 6h
Merged PRs (30d)
1

Description

While trying to resurrect a Go implementation (since go-multicodec is deprecated and archived), I went through multiple phases of what a multicodec library should look like. Only after talking to other members of the IPLD team I came to the conclusion that many of my initial ideas weren't great.

For example, exposing the entire table in an implementation is a bad idea. The table will grow over time, so it will mean higher costs such as memory usage, binary size, and compile time.

Similarly, categorizing the names or codes is not a good idea. The table has a tag field, but it doesn't mean that each of the codes fits neatly into a single category which will remain stable over time. I initially had the idea to give named constants different types in Go to separate the categories and avoid using the wrong type of code, but that turns out to be a bad idea.

Another pitfall would be to implement all of the multicodecs as part of the library, such as via external dependencies. This would mean that importing the multicodec library would suddenly pull hundreds of indirect dependencies, whereas the user likely only needs a tiny minority.

So it seems like the general recommendation should be to just expose a series of named constants for each of the codes. For example, in Go, we could simply code generate:

package multicodec

const (
    Identity = 0x00 // raw binary
    CIDv1 = 0x01 // CIDv1
    [...]

The main advantage here would be that code would be self-explanatory; instead of having:

Codec: 0x71, // dag-cbor

we'd have just:

Codec: multicodec.DagCBOR,

I think this could be a brief section under "Implementations". I imagine that the general recommendations would apply to most languages.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the documentation's "Implementations" section, which the issue identifies as the destination. Add a brief, language-agnostic recommendation covering named constants, avoiding full table exposure, unstable categorization, and broad external dependencies; done means the guidance reflects these points clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
Half a day
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.