RibltDecoder
Defined in: packages/distillate/src/riblt/decoder.ts:48
The receiving side of rateless set reconciliation: fed a peer’s coded symbols in order, it peels them until it holds exactly the keys that differ between the two sets.
Example
Section titled “Example”const decoder = RibltDecoder.from(["alice", "carol"]);Type Parameters
Section titled “Type Parameters”K extends BytesLike = BytesLike
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RibltDecoder<
K>(params?):RibltDecoder<K>
Defined in: packages/distillate/src/riblt/decoder.ts:77
Parameters
Section titled “Parameters”params?
Section titled “params?”RibltParams = {}
Returns
Section titled “Returns”RibltDecoder<K>
Throws
Section titled “Throws”ParamError If seed is not a uint32.
Accessors
Section titled “Accessors”decoded
Section titled “decoded”Get Signature
Section titled “Get Signature”get decoded():
boolean
Defined in: packages/distillate/src/riblt/decoder.ts:113
Whether every received symbol has been peeled: the difference is known.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”add(
key):void
Defined in: packages/distillate/src/riblt/decoder.ts:131
Adds a key this side holds. Keys must be distinct, and all added before the first coded symbol arrives.
Parameters
Section titled “Parameters”K
Returns
Section titled “Returns”void
Throws
Section titled “Throws”ParamError If a coded symbol was already received.
local()
Section titled “local()”local():
K[]
Defined in: packages/distillate/src/riblt/decoder.ts:157
The keys only this side holds, as they were added. Re-hashes each local key once rather than keeping a hash-to-key map over the whole set.
Returns
Section titled “Returns”K[]
push()
Section titled “push()”push(
frame):boolean
Defined in: packages/distillate/src/riblt/decoder.ts:185
Ingests a frame from the peer’s RibltEncoder.take and reports whether the difference is now decoded. Frames must arrive in order. A rejected frame leaves the decoder as it was.
Parameters
Section titled “Parameters”Uint8Array
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”RibltParamMismatchError If the frame’s seed differs.
Throws
Section titled “Throws”ParamError If the frame does not start at the next symbol this decoder expects. On the first frame, if two local keys hash alike under the seed: a repeated key, or a 64-bit collision that another seed resolves.
remote()
Section titled “remote()”remote():
bigint[]
Defined in: packages/distillate/src/riblt/decoder.ts:145
Hashes of the keys only the remote side holds, as RibltDecoder.hashOf gives them.
Returns
Section titled “Returns”bigint[]
from()
Section titled “from()”
staticfrom<K>(keys,params?):RibltDecoder<K>
Defined in: packages/distillate/src/riblt/decoder.ts:89
Builds a decoder over this side’s keys, which must be distinct:
RibltDecoder.push refuses the first frame otherwise.
Type Parameters
Section titled “Type Parameters”K extends BytesLike
Parameters
Section titled “Parameters”Iterable<K>
params?
Section titled “params?”Returns
Section titled “Returns”RibltDecoder<K>
Throws
Section titled “Throws”ParamError If seed is not a uint32.
hashOf()
Section titled “hashOf()”
statichashOf(key,seed?):bigint
Defined in: packages/distillate/src/riblt/decoder.ts:106
The 64-bit hash that RibltDecoder.remote reports for key, so the
peer holding the key can map a reported hash back to it.
Parameters
Section titled “Parameters”BytesLike
number = 0
Returns
Section titled “Returns”bigint
Throws
Section titled “Throws”ParamError If seed is not a uint32.