Skip to content

approach to constants #137

@warpfork

Description

@warpfork

We need to talk about how this library approaches constants.

Currently:

  • There are a bunch of exported caps-lock constant names in the root multihash package, mapping to mulithash indicator codes.
    • Mostly these are caps-lock and s/-/_/g of the names in the multiformats table...
    • But there are also some others, which point to other sibling constants, and are commented as "DEPRECATED" (...what's the point?)
    • There are some other consts that are referring to ranges rather than specific indicator codes (e.g. for the blakes)
    • There are many multihash indicator code numbers which have a function for them made available by the library, but don't have constants (again, the blakes)
  • There's a Codes = map[uint64]string.
    • But it's only good for the things this library knows about (which is not 100% in sync with the table)
  • There's a Names = map[string]uint64, which is the dual of Codes.

... so, there are numerous consistency issues with the current status quo, and it's very manual to update.

And we have a recently born go-multicodec repo, which contains a bunch of constants!

  • it's automatically generated from the csv table! Super nice!
  • contains no other functionality but the constants. Trivial dependency weight (outside of adding a line item to the go.mod file).
  • (one tangent: I wonder if we should rename this repo to go-multiformat. There was pretty resounding agreement that the word multicodec may be confusingly used to describe too many things the last time the IPLD team talked about this. But I also don't feel the need to hold up any other discussion this / if we do engage this, let's spawn another issue for that conversation.)

And, these questions are all raised afresh by #136 -- wherein we've gotta use something for constants in various places; and the revisitation of the registration features means it's a very good time to check in on where we expect any of these mappings to string names to be handled.

Okay, that's all the background. What shall we do? Discuss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions