celestiaorg / smt

A Go library that implements a Sparse Merkle tree for a key-value map.
https://godoc.org/github.com/celestiaorg/smt
MIT License
138 stars 53 forks source link

sanityCheck: only calculate siblingHash if necessary, refactor and reduce code nesting #57

Closed odeke-em closed 3 years ago

odeke-em commented 3 years ago

Only calculate siblingHash to avoid wasting cycles when unneeded. Also while here, reverse conditional the code to reduce nesting and to make reading much simpler.

Fixes #56

odeke-em commented 3 years ago

Kindly cc-ing @cuonglm @adlerjohn @liamsi

codecov-commenter commented 3 years ago

Codecov Report

Merging #57 (f4edc3c) into master (a99c0f5) will decrease coverage by 0.06%. The diff coverage is 100.00%.

:exclamation: Current head f4edc3c differs from pull request most recent head 45292d5. Consider uploading reports for the commit 45292d5 to get more accurate results Impacted file tree graph

@@            Coverage Diff             @@
##           master      #57      +/-   ##
==========================================
- Coverage   85.68%   85.62%   -0.07%     
==========================================
  Files           6        6              
  Lines         468      466       -2     
==========================================
- Hits          401      399       -2     
  Misses         39       39              
  Partials       28       28              
Impacted Files Coverage Δ
proofs.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a99c0f5...45292d5. Read the comment docs.

adlerjohn commented 3 years ago

Thanks @odeke-em!