0.2.0 • Published 9 years ago

bloom-filter v0.2.0

Weekly downloads
1,126
License
-
Repository
-
Last release
9 years ago

bloom-filter

A bloom filter suitable for use in Bitcoin Connection Bloom Filtering as part of BIP37.

Get Started

npm install bloom-filter
var BloomFilter = require('bloom-filter');

// convenient method to initialize the filter
var numberOfElements = 3;
var falsePositiveRate = 0.01;
var filter = BloomFilter.create(numberofElements, falsePositiveRate);

// elements
var a = new Buffer('99108ad8ed9bb6274d3980bab5a85c048f0950c8', 'hex');
var b = new Buffer('19108ad8ed9bb6274d3980bab5a85c048f0950c8', 'hex');
var c = new Buffer('b5a2c786d9ef4658287ced5914b37a1b4aa32eee', 'hex');

// insert elements
filter.insert(a);
filter.insert(b);

// check if elements match
assert(!filter.contains(c));
assert(filter.contains(a));

// reinstantiate from an object
var serialized = filter.toObject();
var filter = new BloomFilter(serialized);

// initialize directly
var filter = new BloomFilter({
  vData: [], // the data of the filter
  nHashFucs: 3, // the number of hash functions to use
  nTweak: 2147483649, // the seed used for the hash fuctions
  nFlags: 0 // flags used to update the filter when matched
});

License

Code released under the MIT license.

Copyright 2015 BitPay, Inc.

@tyz-wallet/tyz-wallet-core-p2p@tyz-wallet/tyz-wallet-core-p2p-cash@tyz-wallet/tyz-wallet-core-p2p-dogebitcore-p2p-usdg@vitruvedz/3dcore-libbitcore-p2p-polisbitcore-p2p-audax@cointobanks/bitcore-p2p-ltp@everything-registry/sub-chunk-1246litecore-p2plitecore-p2p-segwitlibcash-p2plifetioncore-p2plioncore-p2pltzcore-p2pluxcore-p2pguldencore-p2phthcore-libhtmlcoininfo-p2piopcore-p2pmcore-p2p-matrixbitmatrixbitcore-p2pneobitcoin-p2pmulticore-p2pmulticore-p2p-cashmulticore-p2p-mcxneo-blockchain-nodemxbitcore-p2pnpccoincore-libwidecore-p2pzcashcore-p2pxb2p2pwpsecpitcore-p2pposqcore-libpoliscore-p2ppotcore-p2ppcxcore-p2psumcore-p2prawcore-p2pravencore-p2praidencashcore-p2praidencore-p2pufocore-p2psmartcore-p2psexcore-p2pveriumcore-p2pviacore-p2ptuxcore-p2pumbrucore-libulitecore-p2punitedcore-p2punifycore-p2p@vkaxevo/vkaxcore-p2p3dcore-lib@aggregion/gold-record-find@adora-wallet/adoracore-p2p-btc@adora-wallet/adoracore-p2p-cash@adora-wallet/adoracore-p2p-doge@aguycalled/bitcore-p2p@add1ed/bitcore-p2p-messages@gewelio/gewelcore-p2p@gewelio/gewelcore-lib@geekcash/geekcash-p2p@ducatus/bitcore-p2p@duality-solutions/bitcore-p2p-dynamic@duality-solutions/bitcore-lib-dynamic@ducatus/ducatus-core-p2p-rev@ducatus/ducatuscore-p2p@ducatus/ducatuscore-p2p-cash@ducatus/ducatuscore-p2p-duc@ecrypty/florijncoincore-lib@exodus/bitcore-p2p@npccoin/npccoincore-p2p@o0o2022sg/bitcore-p2p@o0o2022sg/bitcore-p2p-cash@o0o2022sg/bitcore-p2p-doge@dashevo/dashcore-lib@dashevo/dashcore-p2p@chaingraph/bitcore-p2p-cash@bitrupee/rapids-p2p@csio.company/dashcore-lib@csio.company/dashcore-p2p@csio.company/dogecore-p2p@captemulation/bitcore-p2p@pacprotocol/pacprotocoljs@pacprotocol/pacprotocoljs-p2p@owstack/bch-p2p@owstack/btc-p2p@pshenmic/dashcore-lib@abcpros/bitcore-p2p@abcpros/bitcore-p2p-bcha@abcpros/bitcore-p2p-cash@abcpros/bitcore-p2p-doge@abcpros/bitcore-p2p-xec@abcpros/bitcore-p2p-xpi@axerunners/axecore-lib@axerunners/axecore-p2p@axerunners/dapi@nanocat/ctrlim
0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago