go-multihash icon indicating copy to clipboard operation
go-multihash copied to clipboard

initial pass converting to string-based multihashes

Open Stebalien opened this issue 7 years ago • 3 comments

TODO:

  • [ ] Consider Nil versus Zero.
  • [ ] Performance (especially better decoding).
  • [ ] Some nice decode method for extracting information from a validated multihash. Need to discuss how this would look.

Updates to reverse-dependencies:

Note: there are a bunch of FIXME(steb) comments in these related to the third todo. Currently, I'm just using mh.Decode(hash.Bytes()) but that kind of sucks.

Stebalien avatar Aug 29 '18 23:08 Stebalien

Ignore the broken CI. That's happening because we can't build GX with this version of go-multihash because it breaks go-multiaddr.

Stebalien avatar Aug 29 '18 23:08 Stebalien

Okay. When I initially did the conversion I tried to do a more complete conversion. If we are okay with leaving DecodedMultihash alone and leaving the functions that work on raw bytes alone I am okay with this. I would suggest we add a SumToBytes() function as that adds no overhead and if there are any external uses that depend on a Multihash being a byte they can likely get by using the combination of the Decode() Encode() and SumToBytes() functions.

I created a second p.r. that continues this one: #84.

kevina avatar Aug 30 '18 17:08 kevina

Performance (especially better decoding).

My FromBinary() takes care of this in #84. I am okay with adding a few more checks but I want this to be fast as so that cid.Hash() is also fast as we can no longer directly cast to a Multihash type.

Some nice decode method for extracting information from a validated multihash.

I think we should keep this simple and just have a Parts() method as I did in #82 and carried over in #84.

kevina avatar Aug 30 '18 17:08 kevina