import { BaseBlock } from '../blocks/base'; import { ParityBlock } from '../blocks/parity'; import { RawDataBlock } from '../blocks/rawData'; /** * FecService provides Forward Error Correction (FEC) functionality. * In the Owner Free Filesystem (OFF), FEC is used to: * 1. Create parity blocks for data recovery * 2. Recover damaged blocks using parity blocks * 3. Ensure data integrity across the network * * This implementation uses Reed-Solomon erasure coding to: * 1. Split data into shards * 2. Create parity shards * 3. Recover lost shards using parity * * @remarks * - All methods validate inputs before processing * - Errors are wrapped in FecError with appropriate context * - The service uses the Reed-Solomon erasure coding library * * @see Requirements 5.1, 5.2, 5.3, 12.1, 12.2 */ export declare class FecService { /** * Given a data buffer, encode it using Reed-Solomon erasure coding. * This will produce a buffer of size (shardSize * (dataShards + parityShards)) * or (shardSize * parityShards) if fecOnly is true. * * @param data - The data to encode * @param shardSize - The size of each shard * @param dataShards - The number of data shards * @param parityShards - The number of parity shards * @param fecOnly - If true, only return parity data * @returns The encoded data * @throws {FecError} If validation fails or encoding fails * * @see Requirements 5.1, 5.2, 5.3 */ encode(data: Uint8Array, shardSize: number, dataShards: number, parityShards: number, fecOnly: boolean): Promise; /** * Given a data buffer, reconstruct/repair it using Reed-Solomon erasure coding. * This will produce a buffer of size (shardSize * dataShards). * * @param data - The data to decode (including parity) * @param shardSize - The size of each shard * @param dataShards - The number of data shards * @param parityShards - The number of parity shards * @param shardsAvailable - Boolean array indicating which shards are available * @returns The decoded data * @throws {FecError} If validation fails or decoding fails * * @see Requirements 5.1, 5.2, 5.3 */ decode(data: Uint8Array, shardSize: number, dataShards: number, parityShards: number, shardsAvailable: boolean[]): Promise; /** * Given an input block, produce a set of parity blocks for error recovery. * * @param input - The input block to create parity for * @param parityBlocks - The number of parity blocks to create * @returns Array of parity blocks * @throws {FecError} If validation fails or parity creation fails * * @see Requirements 5.1, 5.2, 5.3 */ createParityBlocks(input: BaseBlock, parityBlocks: number): Promise; /** * Recover a damaged block using its parity blocks. * * @param damagedBlock - The damaged block to recover * @param parityBlocks - Array of parity blocks for recovery * @returns The recovered raw data block * @throws {FecError} If validation fails or recovery fails * * @see Requirements 5.1, 5.2, 5.3 */ recoverDataBlocks(damagedBlock: BaseBlock, parityBlocks: ParityBlock[]): Promise; } //# sourceMappingURL=fec.service.d.ts.map