-
Notifications
You must be signed in to change notification settings - Fork 47
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
Decide how to handle -1 in Prefix #23
Comments
I think the real problem is we are using Prefix for two different things which I think should be separated. (1) To get information about an existing CD I think we should separate these two concerns. This is espacally relevant now as I am trying to think how to add support for automatically creating Identity hashes. I am tempted to hack on support with the existing Prefix structure but will only make things worse. Instead I propose we use two different structures one to get information about a Cid and another to be used to actually generate a Cid, the first will have a Bytes() method but no Sum() method, and a unsigned MhLength; the latter will not have a Bytes() method, but will have a Sum() method, and a signed MhLength. The latter will also be extended to support creating identity hashes. The only thing is what to call to two structures, should we use Thoughts? |
I agree, Prefix is trying to do too many things. However, is |
Unless I am missing something obvious (always possible) getting the prefix of a Cid() is the only way to get the Version of the cid, although we could add a Version() method fairly easily. Other than that I am not sure and would need to check everywhere Prefix is used. |
For me, the most confusing part is that I don't find the
to the point where the So I think the priority is to first decide at the specification level what role does the prefix play so the user has a clear mental model of it, and later discuss how the code should implement it (if at all) to avoid potential sources of confusion like
The With this I don't want to undermine the Go implementation but (from what I'm understanding from the IPFS model) the specification should always precede the implementation (to avoid having |
FWIW, the JS implementation of the |
I strongly disagree with this. The specification is about the format, not the API. Prefix is an implementation detail. |
If part of the confusion is that the |
And maybe we should just eliminate the use of the word I like using |
That's fair, we may have different expectations of what a specification does. In my experience specifications (e.g., RFCs, what IPFS specs aspire to) tell me more, not just the format but the functions that interact with it, the main components involved, how they interact, the terminology they use, etc. They don't draw the blueprints down to the last level because that's were implementation specific details come up but it's certainly not a black box in terms of what to expect from it. Anyway, thanks for the feedback, this is an interesting discussion (that exceeds this issue) about what to expect from IPFS specifications (I'll try to submit an issue at the specs repo about it). |
Currently,
Prefix.MhLength
is anint
and-1
can be (and is) used to mean "default length". Unfortunately, this means:cid1.Bytes() == cid2.Bytes()
does not implycid1.Prefix() == cid2.Prefix()
.Prefix.Bytes()
is broken.Solutions:
func V1Prefix(codec uint64, mhType uint64) Prefix
). This will break things.Prefix.Bytes()
and provide anEquals
method (less convenient in the long run).Thoughts?
The text was updated successfully, but these errors were encountered: