import { BlockSize } from '../enumerations/blockSize'; import { IBaseBlock } from '../interfaces/blocks/base'; import { Checksum } from '../types/checksum'; import { BaseBlock } from './base'; import { type BlockHandle } from './handle'; import { RawDataBlock } from './rawData'; /** * InMemoryBlockTuple represents a tuple of blocks that can be XORed together. * In the Owner Free Filesystem (OFF), tuples are used for: * 1. Data blocks XORed with random blocks for privacy * 2. Parity blocks XORed for error correction * * This class supports both: * 1. In-memory blocks (IBaseBlock derivatives) for immediate operations * 2. Disk-based blocks (BlockHandle) for persistent storage * * @typeParam T - The block type for blocks in this tuple. Defaults to BaseBlock. * * @example * ```typescript * // Create a tuple from RawDataBlocks * const tuple = InMemoryBlockTuple.fromBlocks(blocks); * * // XOR all blocks together * const result = await tuple.xor(); * ``` * * @see {@link BlockHandle} - Handle type for disk-based blocks * @see {@link BlockHandleTuple} - Tuple specifically for BlockHandle instances * @see Requirements 3.1, 3.2 */ export declare class InMemoryBlockTuple { static readonly TupleSize: number; private readonly _blocks; private readonly _blockSize; private readonly _poolId?; /** * Create a new InMemoryBlockTuple. * * @param blocks - Array of blocks or block handles. Must have exactly TUPLE.SIZE elements. * @param poolId - Optional pool identifier. When set, indicates all blocks in this tuple belong to this pool. * @throws {MemoryTupleError} If the number of blocks is not TUPLE.SIZE * @throws {MemoryTupleError} If blocks have different block sizes */ constructor(blocks: (IBaseBlock | BlockHandle)[], poolId?: string); /** * The pool this tuple belongs to, if any. * When set, indicates all blocks were created in a pool-scoped context. */ get poolId(): string | undefined; /** * Get the block IDs in this tuple */ get blockIds(): Checksum[]; /** * Get the block IDs as a concatenated buffer */ get blockIdsBuffer(): Uint8Array; /** * Get the blocks in this tuple */ get blocks(): (IBaseBlock | BlockHandle)[]; /** * Get the block size for this tuple */ get blockSize(): BlockSize; /** * Convert a Readable stream to a Uint8Array * @param readable - The readable stream to convert * @returns Promise that resolves to a Uint8Array */ private static streamToUint8Array; /** * Convert data to Uint8Array regardless of whether it's a Readable or Uint8Array * @param data - The data to convert * @returns Promise that resolves to a Uint8Array */ private static toUint8Array; /** * XOR all blocks together * @returns A new RawDataBlock containing the XOR result */ xor(): Promise; /** * Create a tuple from block IDs * This creates disk-based blocks using BlockHandle */ static fromIds(blockIDs: Checksum[], blockSize: BlockSize, getBlockPath: (id: Checksum) => string): Promise>; /** * Create a tuple from blocks * This creates in-memory blocks * * @typeParam U - The block type for blocks in the tuple * @param blocks - Array of blocks or block handles * @returns A new InMemoryBlockTuple instance */ static fromBlocks(blocks: (IBaseBlock | BlockHandle)[], poolId?: string): InMemoryBlockTuple; } //# sourceMappingURL=memoryTuple.d.ts.map