Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bloom filter problem when number of elements are low and FPRate is high #253

Open
MBakhshi96 opened this issue Dec 16, 2020 · 0 comments
Open

Comments

@MBakhshi96
Copy link

The length of bloom filter as determined in this line

self.vData = bytearray(int(min(-1 / LN2SQUARED * nElements * math.log(nFPRate), self.MAX_BLOOM_FILTER_SIZE * 8) / 8))

becomes 0 when number of elements nElements is 1 and nFPRate is more than 0.03. This causes every pubkeyhash to return True when checked using contains method.

The way the length of the filter is determined using bytearray also causes some problems, for example for some values, say 0.0005 < nFPRate < 0.01 and nElements = 1 when you change nFPRate the length of the filter doesn't change. This means that regardless of the false positive rate, filter length and its construction is the same. This leads to a wrong false positive rate, different than the parameter passed for filter construction.

A possible fix could be to use bitarray instead of bytearray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant