onflow / atree

Atree provides scalable arrays and scalable ordered maps.
https://onflow.org
Apache License 2.0
39 stars 16 forks source link

Change digest level from int to uint #257

Closed fxamacker closed 2 years ago

fxamacker commented 2 years ago

Description

Digest level must be equal to larger than 0. By changing its data type from int to uint, we can avoid the possiblity of negative value.

Closes #256


codecov-commenter commented 2 years ago

Codecov Report

Merging #257 (ec8d0e4) into main (5494f9e) will decrease coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #257      +/-   ##
==========================================
- Coverage   68.97%   68.94%   -0.03%     
==========================================
  Files          14       14              
  Lines        7245     7245              
==========================================
- Hits         4997     4995       -2     
- Misses       1617     1619       +2     
  Partials      631      631              
Impacted Files Coverage Δ
map_debug.go 55.50% <ø> (ø)
hash.go 71.83% <100.00%> (ø)
map.go 71.41% <100.00%> (ø)
storage.go 79.28% <0.00%> (-0.36%) :arrow_down:

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 5494f9e...ec8d0e4. Read the comment docs.

fxamacker commented 2 years ago

As changing signed to unsigned makes underflow a little "more common" (e.g. decrement of 0 now underflows/wraps around), I checked all changes, and as far as I can see, the code only ever seems to increment the levels. Maybe good to double check though, e.g. that we do not have something like a comparison on something like level-1, like in the other PR

Good point! I just double checked and it looks good.