Fix: Support all hash types in Prefix.sum() - #75
Conversation
7efbc8d to
221efe7
Compare
|
Thanks for another excellent contribution, @sumanjeet0012. This is a clean and well-designed improvement that makes This not only simplifies the implementation by removing duplicate hashing logic, but also ensures future compatibility as additional hash functions are supported by I also appreciate the accompanying test coverage for algorithms such as Overall, this is a valuable improvement that enhances standards compliance while reducing maintenance overhead. LGTM, thanks for the thoughtful contribution and happy to merge. CCing @acul71, @johannamoran and @mishmosh. |
Closes #64
Description
This PR addresses the limitation where
Prefix.sum()andV1Builder.sum()only supportedsha2-256andsha2-512by hardcodinghashlib.sha256/512. The hashing logic now correctly delegates tomultihash.sum()which supports all registered hash functions inpython-multihash.Changes
Prefix.sum()incid/prefix.pyto usemultihash.sum()instead of manually invokinghashliband checkingmh_type.V0Builder.sum()andV1Builder.sum()incid/builder.pysimilarly to delegate tomultihash.sum().hashlibimports from both modules.tests/test_prefix.pyto ensure various multihash types likesha3-256,blake2b-256, andidentityare supported.