-
Notifications
You must be signed in to change notification settings - Fork 57
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
Make Multihash a string instead of a []byte? #29
Comments
The reason i vote in favor of using a |
I suppose that is true. It is really annoying that go does not have a concept of "const" as that can avoid most of these unnecessary copies, for example having to make a copy to pass a string into a function that expects a []byte even though there the function will not modify the data. |
And the argument can also be that more things end up needing it as a string that a Changing the type of Multihash will be a simple but API breaking change. This perhaps should be done at the same time as ipfs/go-cid#3 (if we decide to do that) to minimize the pain. |
I see CIDs used as keys in maps all the time and using a string would help there a lot. Honestly, I'm not sure (we'd have to test it). |
@Stebalien I think you are you are confusing CID with mutlihashes, they are now two different things. |
Ah. Sorry, too many issues open (I care about this because it's one route to make CID's usable as map keys). |
Currently Multihash is defined as:
A multihash may be binary, but it is small and (I hope) immutable. In my view a
string
is a better fit since it will ensure that it will not change. It will also take less memory to point too (two pointers, instead of three).This relates to ipfs/go-cid#3.
The text was updated successfully, but these errors were encountered: