turbofish-org / merk

High-performance Merkle key/value store
Apache License 2.0
226 stars 36 forks source link

Clear TODOs from kv_hash function and node_hash #65

Closed MavenRain closed 1 year ago

MavenRain commented 1 year ago

As the title states, this PR addresses two TODOs related to the kv_hash function. In the first, it changes the behaviour from panicking on a failed range check to returning an error. It also allows for different hashes to be used with the same function. This is achieved by changing the function signature from

fn kv_hash(key: &[u8], value: &[u8]) -> Hash

to

fn kv_hash<D: Digest>(key: &[u8], value: &[u8]) -> Result<Hash, TryFromIntError>

The return type is also reflected in the node_hash function, which changes from

pub fn node_hash(kv: &Hash, left: &Hash, right: &Hash) -> Hash

to

pub fn node_hash<D: Digest>(kv: &Hash, left: &Hash, right: &Hash) -> Hash
codecov-commenter commented 1 year ago

Codecov Report

Merging #65 (4096685) into develop (575b35b) will decrease coverage by 0.04%. The diff coverage is 95.97%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff             @@
##           develop      #65      +/-   ##
===========================================
- Coverage    93.04%   93.01%   -0.04%     
===========================================
  Files           28       28              
  Lines         5147     5166      +19     
===========================================
+ Hits          4789     4805      +16     
- Misses         358      361       +3     
Impacted Files Coverage Δ
src/error.rs 100.00% <ø> (ø)
src/lib.rs 100.00% <ø> (ø)
src/merk/snapshot.rs 0.00% <0.00%> (ø)
src/test_utils/crash_merk.rs 72.91% <0.00%> (ø)
src/test_utils/mod.rs 62.40% <50.00%> (ø)
src/merk/restore.rs 97.09% <71.42%> (-0.36%) :arrow_down:
src/proofs/tree.rs 93.36% <92.00%> (-0.61%) :arrow_down:
src/tree/ops.rs 96.80% <93.93%> (+0.01%) :arrow_up:
src/tree/link.rs 94.13% <95.65%> (+0.04%) :arrow_up:
src/proofs/chunk.rs 96.78% <96.15%> (-0.05%) :arrow_down:
... and 22 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more