Package: eth-bloom
eth-bloomA python implementation of the bloom filter used by Ethereum.This library and repository was previously located athttps://github.com/pipermerriam/ethereum-bloom.  It was transferred to the Ethereum foundation github in November 2017 and renamed toeth-bloom.  The PyPi package was also renamed fromethereum-bloomto `eth-bloom.Read more in the documentation below.View the change log.For more information on what Ethereum Bloom Filters are seehere.Quickstartpython-mpipinstalleth-bloomUsageTheBloomFilterobject>>>frometh_bloomimportBloomFilter>>>b=BloomFilter()>>>b'a value'inb# check whether a value is presentFalse>>>b.add(b'a value')# add a single value>>>b'a value'inbTrue>>>int(b)# cast to an integer3458628712844765018311492773359360516229024449585949240367644166080576879632652362184119765613545163153674691520749911733485693171622325900647078772681584616740134230153806267998022370194756399579977294154062696916779055028045657302214591620589415314367270329881298073237757853875497241510733954508399863880080986777555986663988492288946856978031023631618215522505971170427986911575695114157059398791122395379400594948096>>>bin(b)# cast to a binary string'0b100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'You can also add an iterable of items to a bloom filter.>>>b=BloomFilter()>>>b'value-a'inbFalse>>>b'value-b'inbFalse>>>b.extend([b'value-a',b'value-b'])>>>b'value-a'inbTrue>>>b'value-b'inbTrueYou can initialize a bloom filter from an iterable of byte strings.>>>b=BloomFilter.from_iterable([b'value-a',b'value-b'])# initialize from an iterable of values.>>>b'value-a'inbTrue>>>b'value-b'inbTrueYou can initialize a bloom filter from the integer representation of the bloom bits.>>>b=BloomFilter(3458628712844765018311492773359360516229024449585949240367644166080576879632652362184119765613545163153674691520749911733485693171622325900647078772681584616740134230153806267998022370194756399579977294154062696916779055028045657302214591620589415314367270329881298073237757853875497241510733954508399863880080986777555986663988492288946856978031023631618215522505971170427986911575695114157059398791122395379400594948096)>>>b'a value'inbTrueYou can also merge bloom filters>>>frometh_bloomimportBloomFilter>>>b1=BloomFilter()>>>b2=BloomFilter()>>>b1.add(b'a')>>>b1.add(b'common')>>>b2.add(b'b')>>>b2.add(b'common')>>>b'a'inb1True>>>b'b'inb1False>>>b'common'inb1True>>>b'a'inb2False>>>b'b'inb2True>>>b'common'inb2True>>>b3=b1+b2# using addition>>>b'a'inb3True>>>b'b'inb3True>>>b'common'inb3True>>>b4=b1|b2# or using bitwise or>>>b'a'inb4True>>>b'b'inb4True>>>b'common'inb4True>>>b1|=b2# or using in-place operations (works with += too)>>>b'a'inb1True>>>b'b'inb1True>>>b'common'inb1TrueDeveloper SetupIf you would like to hack on eth-bloom, please check out theSnake Charmers
Tactical Manualfor information on how we do:TestingPull RequestsDocumentationWe usepre-committo maintain consistent code style. Once
installed, it will run automatically with every commit. You can also run it manually
withmake lint. If you need to make a commit that skips thepre-commitchecks, you
can do so withgit commit --no-verify.Development Environment SetupYou can set up your dev environment with:gitclonegit@github.com:ethereum/eth-bloom.gitcdeth-bloom
virtualenv-ppython3venv
.venv/bin/activate
python-mpipinstall-e".[dev]"pre-commitinstallRelease setupTo release a new version:makereleasebump=$$VERSION_PART_TO_BUMP$$How to bumpversionThe version format for this repo is{major}.{minor}.{patch}for stable, and{major}.{minor}.{patch}-{stage}.{devnum}for unstable (stagecan be alpha or beta).To issue the next version in line, specify which part to bump,
likemake release bump=minorormake release bump=devnum. This is typically done from the
master branch, except when releasing a beta (in which case the beta is released from master,
and the previous stable branch is released from said branch).If you are in a beta version,make release bump=stagewill switch to a stable.To issue an unstable version when the current version is stable, specify the
new version explicitly, likemake release bump="--new-version 4.0.0-alpha.1 devnum"