Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/BloomFilter

primitives/BloomFilter

Classes

InvalidBloomFilterLengthError

Defined in: src/primitives/BloomFilter/errors.js:59 Error thrown when BloomFilter data length is invalid

Example

throw new InvalidBloomFilterLengthError(
  'Expected 512 hex chars, got 256',
  {
    value: 256,
    expected: '512 hex chars',
    code: 'BLOOM_FILTER_INVALID_LENGTH',
    docsPath: '/primitives/bloom-filter/from-hex#error-handling'
  }
)

Extends

Constructors

Constructor
new InvalidBloomFilterLengthError(message, options?): InvalidBloomFilterLengthError
Defined in: src/primitives/BloomFilter/errors.js:70
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidBloomFilterLengthError
Overrides
InvalidLengthError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidLengthError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
InvalidLengthError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
InvalidLengthError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
InvalidLengthError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidLengthError.expected
name
name: string
Defined in: src/primitives/BloomFilter/errors.js:79
Inherited from
InvalidLengthError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidLengthError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidLengthError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidLengthError.toJSON

InvalidBloomFilterParameterError

Defined in: src/primitives/BloomFilter/errors.js:19 Error thrown when BloomFilter parameters are invalid

Example

throw new InvalidBloomFilterParameterError(
  'Bloom filter parameters must be positive',
  {
    value: { m, k },
    expected: 'm > 0 and k > 0',
    code: 'BLOOM_FILTER_INVALID_PARAMETER',
    docsPath: '/primitives/bloom-filter/create#error-handling'
  }
)

Extends

Constructors

Constructor
new InvalidBloomFilterParameterError(message, options?): InvalidBloomFilterParameterError
Defined in: src/primitives/BloomFilter/errors.js:30
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidBloomFilterParameterError
Overrides
InvalidRangeError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidRangeError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
InvalidRangeError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
InvalidRangeError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
InvalidRangeError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidRangeError.expected
name
name: string
Defined in: src/primitives/BloomFilter/errors.js:39
Inherited from
InvalidRangeError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidRangeError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidRangeError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidRangeError.toJSON

Type Aliases

BloomFilterType

BloomFilterType = Uint8Array & object
Defined in: src/primitives/BloomFilter/BloomFilterType.ts:3

Type Declaration

[brand]
readonly [brand]: "BloomFilter"
k
readonly k: number
m
readonly m: number
toHex()
toHex(this): string
Parameters
this
BloomFilterType
Returns
string

Variables

BITS

const BITS: 2048 = 2048
Defined in: src/primitives/BloomFilter/constants.js:11 Number of bits in the bloom filter (2048)

DEFAULT_HASH_COUNT

const DEFAULT_HASH_COUNT: 3 = 3
Defined in: src/primitives/BloomFilter/constants.js:17 Default number of hash functions for Ethereum bloom filters

SIZE

const SIZE: 256 = 256
Defined in: src/primitives/BloomFilter/constants.js:5 Standard Ethereum bloom filter size in bytes (256 bytes = 2048 bits)

Functions

add()

add(filter, item): void
Defined in: src/primitives/BloomFilter/index.ts:21

Parameters

filter
BloomFilterType
item
Uint8Array

Returns

void

BloomFilter()

BloomFilter(m, k): BloomFilterType
Defined in: src/primitives/BloomFilter/index.ts:74 Factory function for creating BloomFilter instances

Parameters

m
number
k
number

Returns

BloomFilterType

combine()

combine(…filters): BloomFilterType
Defined in: src/primitives/BloomFilter/index.ts:25

Parameters

filters
BloomFilterType[]

Returns

BloomFilterType

contains()

contains(filter, item): boolean
Defined in: src/primitives/BloomFilter/index.ts:29

Parameters

filter
BloomFilterType
item
Uint8Array

Returns

boolean

create()

create(m, k): BloomFilterType
Defined in: src/primitives/BloomFilter/index.ts:33

Parameters

m
number
k
number

Returns

BloomFilterType

density()

density(filter): number
Defined in: src/primitives/BloomFilter/index.ts:37

Parameters

filter
BloomFilterType

Returns

number

expectedFalsePositiveRate()

expectedFalsePositiveRate(filter, itemCount): number
Defined in: src/primitives/BloomFilter/index.ts:41

Parameters

filter
BloomFilterType
itemCount
number

Returns

number

fromHex()

fromHex(hex, m, k): BloomFilterType
Defined in: src/primitives/BloomFilter/index.ts:48

Parameters

hex
string
m
number
k
number

Returns

BloomFilterType

hash()

hash(item, seed, m): number
Defined in: src/primitives/BloomFilter/index.ts:52

Parameters

item
Uint8Array
seed
number
m
number

Returns

number

isEmpty()

isEmpty(filter): boolean
Defined in: src/primitives/BloomFilter/index.ts:56

Parameters

filter
BloomFilterType

Returns

boolean

merge()

merge(filter1, filter2): BloomFilterType
Defined in: src/primitives/BloomFilter/index.ts:60

Parameters

filter1
BloomFilterType
filter2
BloomFilterType

Returns

BloomFilterType

toHex()

toHex(filter): string
Defined in: src/primitives/BloomFilter/index.ts:67

Parameters

filter
BloomFilterType

Returns

string