Open vmx opened 4 years ago
I worry that the rules for detecting whether or not a binary value is a CID or a multihash (CIDv0) are problematic, which is why I cut that behavior from the re-write and require explicit version setting for CIDv0. That could be replaced with a CIDv0 constructor but it would be a little odd to have a CIDv0 constructor and also support string encoded CIDv0 in the normal constructor (which we really need to do in order to keep the interface usable).
I’m fine having to jump through extra hoops to instantiate a CIDv0 from a binary value because you really need to be doing some detection on your own for that case, but there’s lots of places where we accept string encoded CID’s and need easy backwards compatibility. We also have a more reliable detection mechanism (starts with “Q”) for strings.
I suggest that the
version
is removed from the constructor and that it is always v1 automatically. There could be a dedicatedv0
constructor, or we just allow constructing it by multihash (which is probably most of its uses).