polyswarmclient.ethereum.bloom

Module Contents

polyswarmclient.ethereum.bloom.FILTER_BITS[source]
polyswarmclient.ethereum.bloom.HASH_FUNCS = 8[source]
polyswarmclient.ethereum.bloom.logger[source]
class polyswarmclient.ethereum.bloom.BloomFilter(value=0)[source]

Bases: numbers.Number

value[source]
__int__(self)[source]
add(self, value)[source]

Add a single byte value to the Bloom filter.

Parameters

value (bytes) – Byte encoded value to add to Bloom filter.

extend(self, iterable)[source]

Add an iterable of byte values to the bloom filter.

Parameters

iterable (Iterable[bytes]) – Iterable of byte values.

classmethod from_iterable(cls, iterable)[source]

Instantiate a bloom filter from a given iterable.

Parameters

iterable (Iterable[bytes]) – Iterable of byte values.

Returns

Instantiated BloomFilter.

Return type

BloomFilter

__contains__(self, value)[source]
__index__(self)[source]
_combine(self, other)[source]
__or__(self, other)[source]
__add__(self, other)[source]
_icombine(self, other)[source]
__ior__(self, other)[source]
__iadd__(self, other)[source]
static get_bloom_bits(value)[source]

Bloom filter helper function. Get the Bloom bits of a given value.

Parameters

value (bytes) – Value to be encoded into the Bloom filter.

static get_chunks_for_bloom(value_hash)[source]

Bloom filter helper function. Turn a value hash into a series of chunks.

Parameters

value_hash (bytes) – Hash of to be encoded into the Bloom filter.

Yields

chunk (bytes) – Chunks of the value hash.

static chunk_to_bloom_bits(chunk)[source]

Bloom filter helper function. Turn a chunk into a series of actual bytes.

Parameters

chunk (bytes) – Byte encoded chunk.