diff --git a/lib/utils/bloom.js b/lib/utils/bloom.js index a8f696c2..2fe23837 100644 --- a/lib/utils/bloom.js +++ b/lib/utils/bloom.js @@ -272,6 +272,7 @@ Bloom.fromRate = function fromRate(items, rate, update) { assert(rate >= 0 && rate <= 1, '`rate` must be between 0.0 and 1.0.'); size = (-1 / LN2SQUARED * items * Math.log(rate)) | 0; + size = Math.max(8, size); if (update !== -1) size = Math.min(size, Bloom.MAX_BLOOM_FILTER_SIZE * 8); @@ -433,6 +434,7 @@ RollingFilter.prototype.fromRate = function fromRate(items, rate) { items = ((size + 63) / 64 | 0) << 1; items >>>= 0; + items = Math.max(1, items); tweak = (Math.random() * 0x100000000) >>> 0;