wnfs-wg / deterministic-bloom

A deterministic Bloom filter with support for saturation. Suitable for distributed use cases and as a cryptographic primitive.
Apache License 2.0
0 stars 0 forks source link

Correctly handle empty bloom filters, avoid infinite loop #9

Closed matheus23 closed 1 year ago

matheus23 commented 1 year ago

HashIndexIterator used to loop infinitely when bit_size was 0, because it wouldn't be able to generate a random index that's < 0 (fair enough).

Now it simply exists instantly if bit_size == 0.

Also added a test case for empty blooms. They "technically" contain everything as a false positive. I opted for that, rather than "an empty bloom contains nothing", since that keeps the invariant that if you .insert something into a bloom filter, it will always be contained.

codecov[bot] commented 1 year ago

Codecov Report

Merging #9 (96ef951) into main (a8cd85b) will decrease coverage by 0.18%. The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main       #9      +/-   ##
==========================================
- Coverage   73.50%   73.33%   -0.18%     
==========================================
  Files           5        5              
  Lines         117      120       +3     
  Branches       15       16       +1     
==========================================
+ Hits           86       88       +2     
  Misses         21       21              
- Partials       10       11       +1     
Files Changed Coverage Δ
deterministic-bloom/src/runtime_size.rs 77.77% <ø> (ø)
deterministic-bloom/src/common.rs 81.39% <50.00%> (-1.11%) :arrow_down: