Class: RollingFilter

utils.RollingFilter

new RollingFilter(items, rate)

A rolling bloom filter used internally (do not relay this on the p2p network).

Parameters:
Name Type Description
items Number

Expected number of items.

rate Number

False positive rate (0.0-1.0).

Source:

Methods

(static) fromRate(items, rate) → {RollingFilter}

Instantiate rolling filter from items and FPR.

Parameters:
Name Type Description
items Number

Expected number of items.

rate Number

False positive rate (0.0-1.0).

Source:
Returns:
Type
RollingFilter

add(val, encnullable)

Add data to the filter.

Parameters:
Name Type Attributes Description
val Buffer | String
enc String <nullable>

Can be any of the Buffer object's encodings.

Source:

added(val, encnullable) → {Boolean}

Test whether data is present in the filter and potentially add data.

Parameters:
Name Type Attributes Description
val Buffer | String
enc String <nullable>

Can be any of the Buffer object's encodings.

Source:
Returns:

Whether data was added.

Type
Boolean

(private) fromRate(items, rate) → {RollingFilter}

Inject properties from items and FPR.

Parameters:
Name Type Description
items Number

Expected number of items.

rate Number

False positive rate (0.0-1.0).

Source:
Returns:
Type
RollingFilter

hash(val, seed) → {Number}

Perform the mumur3 hash on data.

Parameters:
Name Type Description
val Buffer
seed Number
Source:
Returns:
Type
Number

reset()

Reset the filter.

Source:

test(val, encnullable) → {Boolean}

Test whether data is present in the filter.

Parameters:
Name Type Attributes Description
val Buffer | String
enc String <nullable>

Can be any of the Buffer object's encodings.

Source:
Returns:
Type
Boolean