moolb-js

Bloom filter for javascript with pluggable hasher backend
git clone git://git.defalsify.org/moolb-js.git
Log | Files | Refs | README

commit 7cd7011ab5041fb81667c514a86cab12a113a4ed
parent 5d1e01f54efbe0e7fdaea1579682fafd2890b8c5
Author: nolash <dev@holbrook.no>
Date:   Thu, 29 Oct 2020 22:17:05 +0100

Add false case in output

Diffstat:
Mbloom.js | 22+---------------------
1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/bloom.js b/bloom.js @@ -61,27 +61,6 @@ Bloom.prototype.check = function(blockNumber) { return ok; }; -// merges the bloom filter bytes in parameter with the object's -// \param bloomBytes bytes to merge. MUST be equal length of object's -// \return true on success, false on fail -Bloom.prototype.merge = function(bloomBytes) { - if (bloomBytes.length != this.filter.length) { - console.error("lengths must match (" + bloomBytes + " != " + this.filter.length); - return false; - } - for (var i = 0; i < this.filter.length; i++) { - if (this.filter[i] != bloomBytes[i]) { - dbg("merging " + ": before " + this.filter[i] + " after " + (this.filter[i] | bloomBytes[i])); - this.filter[i] |= bloomBytes[i]; - } - } - return true; -}; - -// returns the actual bytes of the bloomfilter -Bloom.prototype.bytes = function() { - return this.filter; -}; // a single bloom hash round function hashBloom(data, salt) { @@ -98,3 +77,4 @@ a = new Uint8Array(bloomBytes); b = new Bloom(a); b.add(1024); console.log(b.check(1024)); +console.log(b.check(1023));