Each entry in constants.py currently stores only the codec prefix code. The upstream multicodec table.csv has 5 columns (name, tag, code, status, description), but tools/update-table.py discards tag, status, and description during generation.
Problem
Current format in constants.py:
CODECS = {
"sha2-256": {"prefix": 0x12},
"dag-pb": {"prefix": 0x70},
"ip4": {"prefix": 0x04},
}
The upstream CSV contains significantly more information per codec:
| name |
tag |
code |
status |
description |
| sha2-256 |
multihash |
0x12 |
permanent |
|
| dag-pb |
ipld |
0x70 |
permanent |
|
| ip4 |
multiaddr |
0x04 |
permanent |
|
| shake-128 |
multihash |
0x18 |
draft |
|
This metadata is discarded by tools/update-table.py (line 82), which only writes the prefix:
# tools/update-table.py, line 82:
value = "{'prefix': {code}, },".format(code=codec["code"])
Proposed Solution
-
Modify tools/update-table.py to include tag, status, and description in the output:
"sha2-256": {"prefix": 0x12, "tag": "multihash", "status": "permanent", "description": ""},
-
Regenerate constants.py using the updated script.
-
Add Code.status and Code.description properties in code.py that read from the enriched CODECS dict.
-
Update NAME_TABLE and CODE_TABLE derivations to remain backward-compatible (they only need name↔prefix mapping).
-
Add tests verifying that every codec has tag, status fields populated.
Related
- Generator script:
tools/update-table.py
- Go equivalent: go-multicodec includes status ("permanent"/"draft") and description in generated code comments
Each entry in
constants.pycurrently stores only the codec prefix code. The upstream multicodec table.csv has 5 columns (name,tag,code,status,description), buttools/update-table.pydiscardstag,status, anddescriptionduring generation.Problem
Current format in
constants.py:The upstream CSV contains significantly more information per codec:
This metadata is discarded by
tools/update-table.py(line 82), which only writes theprefix:Proposed Solution
Modify
tools/update-table.pyto includetag,status, anddescriptionin the output:Regenerate
constants.pyusing the updated script.Add
Code.statusandCode.descriptionproperties incode.pythat read from the enrichedCODECSdict.Update
NAME_TABLEandCODE_TABLEderivations to remain backward-compatible (they only need name↔prefix mapping).Add tests verifying that every codec has
tag,statusfields populated.Related
tools/update-table.py