vechain-sdk-js
vechain-sdk-js copied to clipboard
Extend the Bloom `Filter` to support operands.
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 propertiesk
andm
; - to use
n
as parameter to compute the bestk
by default oncem
is set. (m
should depend on the probability of the of false positive accepted, hence is a function ofn
as well); - to provide a method to check if different filters are compatible;
- to provide a method to merge filters in a new.