vechain-sdk-js icon indicating copy to clipboard operation
vechain-sdk-js copied to clipboard

Extend the Bloom `Filter` to support operands.

Open lucanicoladebiasi opened this issue 10 months ago • 0 comments

As SDK user I wish to combine different Bloom filters to check if an element (address) is possibly part of multiple Thor's blocks get in different moments.


Bloom Filter class depends from the parameters

  • k : number of hash functions used to generate the filter,
  • m : number of bits per key in the filter used to represent an entry in the set of elements the filter represents.

The two parameters are related: if we set n as the number of elements of the set generating the filter, k = ln(2) * m / n.

Different Bloom filters can't be combined if m and k were different when the filters were computed.

The goal of the ticket is

  • to add to the Filter class the properties k and m;
  • to use n as parameter to compute the best k by default once m is set. (m should depend on the probability of the of false positive accepted, hence is a function of n as well);
  • to provide a method to check if different filters are compatible;
  • to provide a method to merge filters in a new.

lucanicoladebiasi avatar Apr 18 '24 07:04 lucanicoladebiasi