Skip to content

Documentation / @etherfold/browser / streamAddress

Function: streamAddress() ​

streamAddress<ABI>(name, source, streamConfig): object

Defined in: packages/browser/src/storage/stream/OnIndexedDB.ts:93

Where the stream a {source, config} resolves to lives. See streamSubtree.

Type Parameters ​

ABI ​

ABI extends Abi

Parameters ​

name ​

string

source ​

IndexingSource<ABI>

streamConfig ​

UsedStreamConfig

Returns ​

cursor ​

cursor: IDBValidKey

prefix ​

prefix: IDBValidKey[]

segment ​

segment: (ordinal) => IDBValidKey

Parameters ​

ordinal ​

number

Returns ​

IDBValidKey

segments ​

segments: IDBKeyRange

The two ranges, which are NOT the same and using the wrong one is a real bug.

IndexedDB orders number < string < array. So the SUBTREE range, whose upper bound is an empty ARRAY, spans the 'cursor' record along with the ordinals -- which is what clear wants and what keeps the cursor from being orphaned by a scoped delete. A SEGMENTS-ONLY read has to exclude the string bound, or a full ordered scan would come back with the cursor record sitting in it as though it were a segment.

The subtree's LOWER bound is the prefix itself (exclusive) rather than ordinal 0, so it spans every key below this digest whatever its last element is. That matters to the registry's sweep, which drops subtrees written by code that is GONE: what a dead digest rule put down there is not this module's to assume.

subtree ​

subtree: IDBKeyRange