• Performs binary search in the gallery index B-tree. The search is performed recursively, traversing the tree based on key comparisons. At each node:

    1. Compare the search key with node keys
    2. If exact match found, return associated data
    3. If no match, recurse into appropriate child node
    4. If leaf node reached with no match, return undefined

    Parameters

    • key: Uint8Array<ArrayBufferLike>

      Search key (4 bytes from SHA-256 hash)

    • node: Node

      Current node being searched

    • version: string

      Gallery index version

    Returns Promise<[bigint, number] | undefined>

    Tuple of [offset, length] pointing to matching gallery data, or undefined if not found

    const key = await sha256First4Bytes("search term");
    const rootNode = await getNodeAtAddress(0n, version);
    const result = await binarySearch(key, rootNode, version);