Giter Club home page Giter Club logo

Comments (6)

vmx avatar vmx commented on June 12, 2024 1

I have to admit I'm not fully convinced of the use case. I'm also cautious about having a bigger public API surface.

To conclude: There currently is a way to create Multihashes with a truncated hash via wrap(). We could introduce a convenient methods, once it shows up as a repeated pattern.

I'm closing this issue for now.

from rust-multihash.

rklaehn avatar rklaehn commented on June 12, 2024

I see that this can be implemented in terms of wrap, but I still think that it would be nice to have a dedicated method for this...

from rust-multihash.

vmx avatar vmx commented on June 12, 2024

There is no way to produce e.g. a multihash that uses Sha2_256 but only stores 16 bytes of hash data.

There is a way, you can call wrap().

Hence I don't know if there should be a truncate() method at all. In case there should be one, perhaps it would be one on digest creation time, something like digest_truncated(data, length).

from rust-multihash.

rklaehn avatar rklaehn commented on June 12, 2024

I don't think there is a benefit in doing this at digest creation time, since you have to generate the full hash anyway. Having discovered wrap, this is more a convenience method than a necessity. The question is how common this use case is, and if a convenience method is warranted.

from rust-multihash.

vmx avatar vmx commented on June 12, 2024

I don't think there is a benefit in doing this at digest creation time, since you have to generate the full hash anyway.

My thoughts came from the opposite direction. I don't think there is a benefit doing the truncation outside the digest creation as you would create a digest anyway.

from rust-multihash.

rklaehn avatar rklaehn commented on June 12, 2024

I can see cases where you already have a multihash from somewhere and want to truncate it, or you have two multihashes with different lengths and want to check whether they could refer to the same data.

But maybe let's leave this open and decide if and how to implement it once we have better use case examples. Should not take long.

from rust-multihash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.