0.2.0 • Published 11 years ago

bloom-filter v0.2.0

Weekly downloads
1,126
License
-
Repository
-
Last release
11 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-1246widecore-p2pwpsecxb2p2psumcore-p2pviacore-p2pveriumcore-p2pguldencore-p2phtmlcoininfo-p2phthcore-libiopcore-p2plioncore-p2plifetioncore-p2plitecore-p2plitecore-p2p-segwitlibcash-p2pltzcore-p2pluxcore-p2pmatrixbitcore-p2pmcore-p2p-matrixbit@weicrypto/weicore-lib@weicrypto/weicore-p2p@xazabevo/xazabcore-p2p@xazab/xazabcore-lib@xazab/xazabcore-p2p@xazabevo/xazabcore-lib@umbru/umbrucore-lib@unifyroom/unfycore-lib@towercg-plugins/twitch-server@upincome/c0bancore-p2p@vkaxevo/vkaxcore-p2p@vpubevo/vpubcore-p2palterdot-libalterdot-p2p@zipeva/zipcore-lib@zipeva/zipcore-p2p@zipevo/zipcore-libalarmxcore-p2paxecore-p2paudax-bitcore-p2pb2p2partbytecore-p2p@gohelpfund/helpcore-p2p3dcore-lib@abcpros/bitcore-p2p@abcpros/bitcore-p2p-bcha@abcpros/bitcore-p2p-cash@abcpros/bitcore-p2p-doge@abcpros/bitcore-p2p-xec@abcpros/bitcore-p2p-xpi@guusevo/guuscore-lib@guusevo/guuscore-p2p@aggregion/gold-record-find@aguycalled/bitcore-p2p@add1ed/bitcore-p2p-messages@adora-wallet/adoracore-p2p-btc@adora-wallet/adoracore-p2p-cash@adora-wallet/adoracore-p2p-doge@ecrypty/florijncoincore-libufocore-p2pumbrucore-libulitecore-p2punitedcore-p2ptuxcore-p2p@bitrupee/rapids-p2p@captemulation/bitcore-p2p@chaingraph/bitcore-p2p-cashzcashcore-p2punifycore-p2p@murgor/mvs-p2p@neo-one/node-protocol@neo-one/node-protocol-browserify@neo-one/node-protocol-es2018-cjs@neo-one/node-protocol-esnext-cjs@neo-one/node-protocol-esnext-esm@nanocat/ctrlim@pshenmic/dashcore-lib@owstack/bch-p2p@owstack/btc-p2p@pacprotocol/pacprotocoljs@pacprotocol/pacprotocoljs-p2pmxbitcore-p2pmulticore-p2pmulticore-p2p-cashmulticore-p2p-mcxnpccoincore-libpcxcore-p2pravencore-p2prawcore-p2pneobitcoin-p2pneo-blockchain-nodepitcore-p2p
0.2.0

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago