Skip to content

RibltEncoder

Defined in: packages/distillate/src/riblt/encoder.ts:33

The sending side of rateless set reconciliation: turns a key set into an endless stream of coded symbols, a prefix of which lets a peer holding a similar set decode exactly the keys that differ.

const encoder = RibltEncoder.from(["alice", "bob"]);

new RibltEncoder(params?): RibltEncoder

Defined in: packages/distillate/src/riblt/encoder.ts:50

RibltParams = {}

RibltEncoder

ParamError If seed is not a uint32.

add(key): void

Defined in: packages/distillate/src/riblt/encoder.ts:76

Adds a key. Keys must be distinct, and all added before the first coded symbol is produced.

BytesLike

void

ParamError If a coded symbol was already produced.


stream(n): Generator<Uint8Array<ArrayBufferLike>, never, undefined>

Defined in: packages/distillate/src/riblt/encoder.ts:111

Yields consecutive RibltEncoder.take frames of n symbols forever; the caller stops once the peer reports it has decoded.

number

Generator<Uint8Array<ArrayBufferLike>, never, undefined>

ParamError On the first next(), if n is not a positive integer or the keys are not distinct, as RibltEncoder.take does.


take(n): Uint8Array

Defined in: packages/distillate/src/riblt/encoder.ts:96

Produces the next n coded symbols as one frame, for the peer’s RibltDecoder.push. Frames must reach the decoder in order.

number

Uint8Array

ParamError If n is not a positive integer. On the first frame, if two keys hash alike under the seed: a repeated key, or a 64-bit collision that another seed resolves.


static from(keys, params?): RibltEncoder

Defined in: packages/distillate/src/riblt/encoder.ts:62

Builds an encoder over keys, which must be distinct: RibltEncoder.take refuses the first frame otherwise.

Iterable<BytesLike>

RibltParams

RibltEncoder

ParamError If seed is not a uint32.