GithubHelp home page GithubHelp logo

Comments (7)

vmx avatar vmx commented on June 9, 2024

Thanks for the suggestion. I agree that the current API is not as nice as it could be. Though there is a reason why the MultihashDigest is what it is today. I deliberately decided (see #63 (comment) for more information) that I don't want to introduce another trait. I want to have a trait that also works for trait objects. The digest crate has two different traits (Digest and DigestDyn) for that reason. I wanted to get away with only a single one. I prefer APIs where there's only one way of doing things.

Hence I suggest that for libipld, we use the MultihashDigest for now and if it turns out to be used a lot and hence it's unergonomic or if it becomes a performance bottleneck, we can still introduce it then.

from rust-multihash.

dvc94ch avatar dvc94ch commented on June 9, 2024

but libp2p actually uses it in the same way, so it's costing both libipld and libp2p a heap allocation, for no reason

from rust-multihash.

vmx avatar vmx commented on June 9, 2024

IIRC, the usage in libp2p needs it to be a trait object. But I'll check again tomorrow.

from rust-multihash.

dvc94ch avatar dvc94ch commented on June 9, 2024

No it just requires a digest function on code. That can be implemented without boxing it first

from rust-multihash.

vmx avatar vmx commented on June 9, 2024

Yes, it could be used without a trait. My idea was that custom code tables work with the whole ecosystem. This way every code table would also need to implement a digest() function. That might be OK for libp2p as it probably will never use a custom codec table. Though that's not true for IPLD.

from rust-multihash.

dvc94ch avatar dvc94ch commented on June 9, 2024

So what we need is a different trait, a Code trait that includes a digest function?

from rust-multihash.

dvc94ch avatar dvc94ch commented on June 9, 2024

In any case can you merge the cid pr and review the ipld pr? Then we can revisit the issue...

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.