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
Added map of string to codecs #26
Conversation
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cid_test.go
Outdated
for k, v := range tCodes { | ||
if Codecs[v] != k { | ||
t.Errorf("Table mismatch: 0x%x %s", k, v) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should probably be a len(tCodes) == len(Codecs) - 1
test here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stebalien improved the tests. Added the one requested.
cid.go
Outdated
@@ -79,6 +79,28 @@ const ( | |||
ZcashTx = 0xc1 | |||
) | |||
|
|||
// Codecs maps the name of a codec to its type | |||
var Codecs = map[string]byte{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that byte is right format for it.
The codecs are not limited to a byte (due to varint) we just are trying to keep codecs that are being used in cid in the 8 bit range but it might not be much longer till we will have two byte CID codecs (we already have two and three byte multihashes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably be uint64
as in https://github.com/ipfs/go-cid/blob/master/cid.go#L109
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kubuxu fixed
Example
Very useful for
ipfs block put --format <format> --mhtype <mhtype> <object>