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 improvement #607

Open
JeneaVranceanu opened this issue Aug 11, 2022 · 1 comment
Open

Bloom filter improvement #607

JeneaVranceanu opened this issue Aug 11, 2022 · 1 comment

Comments

@JeneaVranceanu
Copy link
Collaborator

Here you can find an implementation of a bloom filter that could be used to implement a better version of bloom9.
Looks like this link is unsecured due to issues with SSL certificate so I copied the code snippet.

This is not certain but looks like we can try to follow this example and potentially improve performance of bloom filter calculation:

# external imports
import sha3

class LogBloom:

    def __init__(self):
        self.content = bytearray(256)


   def add(self, element):
       if not isinstance(element, bytes):
           raise ValueError('element must be bytes')
        h = sha3.keccak_256()
        h.update(element)
        z = h.digest()

        for j in range(3):
            c = j * 2
            v = int.from_bytes(z[c:c+2], byteorder='big')
            v &= 0x07ff
            m = 255 - int(v / 8)
            n = v % 8
            self.content[m] |= (1 << n)
@JeneaVranceanu JeneaVranceanu changed the title Bloom filter improvement by refactoring Refactoring: Bloom filter improvement Aug 11, 2022
@Kristenlike1234 Kristenlike1234 added the FAQ common questions tend to recur about web3 infra label Oct 4, 2022
@JeneaVranceanu
Copy link
Collaborator Author

@Kristenlike1234 This improvement is not implemented/tried out yet.
The PR that was merged is mostly clean up, DocC update and slight performance improvement over the previous implementation.

@Kristenlike1234 Kristenlike1234 added bug Something isn't working and removed FAQ common questions tend to recur about web3 infra bug Something isn't working labels Oct 6, 2022
@yaroslavyaroslav yaroslavyaroslav changed the title Refactoring: Bloom filter improvement Bloom filter improvement Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants