-
Notifications
You must be signed in to change notification settings - Fork 49
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
PartialEq, Hash, PartialOrd across Cid versions #66
Comments
Thanks for bringing it up. This is something that should work the same across implementations, hence I've opened multiformats/cid#41 for general discussions about it. |
They will have the same Multihash. You can always convert a CIDv0 to a CIDv1 (in case you don't want to be bothered about it, you can do that whenever you encoder a CIDv0), or you can compare the hash instead, e.g. As I understand the Other implementations (Go, JS) take the version into account for equality, so the idea is that "equal" means byte-identical (which CIDv0 and CIDv1 are not). |
Thanks, we have been doing both of these in rust-ipfs. The reason why I was asking this was to find out the use case the equality is based on.
I read this sentence as you find the documentation for Hash implying its implementations MUST account for all fields, but I don't think that is the case, and I would be surprised to learn it was. It is however what the default derive does and in most cases it is the correct thing to do. What is important regarding Hash trait is the
Apologies, I was not being clear enough but I was thinking the Cid should behave like
There must then be a need to retain the original formatting information. Perhaps it has just not occured to me yet :) |
I replied the above before checking the linked |
No, I don't think it MUST. Just as you said, it's the common thing to do to include all fields.
Good point. I'll watch out for one and let you know if I find one. |
Similar to #59 at the moment (0.5.1) the Cid is not equal across cid versions. I did not find anything from the specs or original posts on Cidv1 extension about this, but my intuition says
cid::Version::V0
is merely a formatting option forstd::fmt::Display
.What are the situations where
V0
cid should not be equal to the same multihash andcid::Codec::DagProtobuf
asV1
? I guess the only valid use case is to separate on theCid::version(&self)
but for all content identification or addressing purposes these should be equal even if they have different string representations?The text was updated successfully, but these errors were encountered: