import { BaseBlock } from '../blocks/base'; import { BlockHandle } from '../blocks/handle'; import { RawDataBlock } from '../blocks/rawData'; import { BlockSize } from '../enumerations/blockSize'; import { IFecService } from '../interfaces/services/fecService'; import { BlockStoreOptions, IBlockMetadata } from '../interfaces/storage/blockMetadata'; import type { CBLStorageResult, CBLWhiteningOptions } from '../interfaces/storage/cblWhitening'; import { IPooledBlockStore, ListOptions, PoolDeletionValidationResult, PoolId, PoolStats } from '../interfaces/storage/pooledBlockStore'; import { Checksum } from '../types/checksum'; import { MemoryBlockMetadataStore } from './memoryBlockMetadataStore'; import { MemoryBlockStore } from './memoryBlockStore'; /** * In-memory implementation of IPooledBlockStore. * * Extends MemoryBlockStore with pool-based namespace isolation. * Blocks are stored in a separate pool-scoped map keyed by storage keys * (format: "${poolId}:${hash}"). Legacy IBlockStore methods delegate * to the DEFAULT_POOL for backward compatibility. * * @see IPooledBlockStore for the interface definition * @see MemoryBlockStore for the base implementation */ export declare class PooledMemoryBlockStore extends MemoryBlockStore implements IPooledBlockStore { /** Pool-scoped block storage: storageKey -> block data */ private readonly poolBlocks; /** Per-pool statistics */ private readonly poolStatsMap; constructor(blockSize: BlockSize, fecService?: IFecService | null, metadataStore?: MemoryBlockMetadataStore); /** * Compute the SHA3-512 hash of data and return as hex string. */ private computeHash; /** * Update pool statistics after a block is added. */ private recordPut; /** * Update pool statistics after a block is removed. */ private recordDelete; /** * Touch the lastAccessedAt timestamp for a pool. */ private touchPool; hasInPool(pool: PoolId, hash: string): Promise; getFromPool(pool: PoolId, hash: string): Promise; putInPool(pool: PoolId, data: Uint8Array, options?: BlockStoreOptions): Promise; deleteFromPool(pool: PoolId, hash: string): Promise; listPools(): Promise; listBlocksInPool(pool: PoolId, options?: ListOptions): AsyncIterable; getPoolStats(pool: PoolId): Promise; deletePool(pool: PoolId): Promise; /** * Internal deletion logic shared by deletePool (after validation) and forceDeletePool. * Removes all blocks with the pool prefix and clears pool stats. */ private performPoolDeletion; /** * Get random block checksums scoped to a specific pool. * Iterates storage keys with the pool prefix and randomly selects blocks. * @param pool - The pool to source random blocks from * @param count - Number of random blocks requested * @returns Array of checksums (may be fewer than count if pool has insufficient blocks) */ getRandomBlocksFromPool(pool: PoolId, count: number): Promise; /** * Override getRandomBlocks to use Default_Pool for backward compatibility. * Delegates to getRandomBlocksFromPool with DEFAULT_POOL. */ getRandomBlocks(count: number, _blockSize: BlockSize): Promise; /** * Seed a pool with cryptographically random blocks for whitening material. * Stub — full implementation in task 5.1. */ bootstrapPool(pool: PoolId, blockSize: BlockSize, count: number): Promise; /** * Check whether a pool can be safely deleted (no cross-pool XOR dependencies). * Scans all other pools' blocks looking for CBL-type blocks whose addresses * reference checksums stored in the target pool. * * @param pool - The pool to validate for deletion * @returns Validation result with dependency details if unsafe */ validatePoolDeletion(pool: PoolId): Promise; /** * Check if raw block data represents a CBL-type block. * CBL blocks have the BrightChain magic prefix (0xBC) followed by a CBL structured type. */ private isCblBlock; /** * Extract addresses from a CBL block's raw data. * Returns null if the block is encrypted or cannot be parsed. */ private extractCblAddresses; /** * Delete a pool without checking for cross-pool dependencies. * For administrative use only — bypasses validatePoolDeletion. */ forceDeletePool(pool: PoolId): Promise; /** * Store a CBL with XOR whitening, scoped to a specific pool. * Both XOR component blocks are stored within the specified pool namespace. * * @param pool - The pool to store the whitened CBL components in * @param cblData - The original CBL data as Uint8Array * @param options - Optional storage options (durability, expiration, encryption flag) * @returns Result containing block IDs, parity IDs (if any), and magnet URL */ storeCBLWithWhiteningInPool(pool: PoolId, cblData: Uint8Array, options?: CBLWhiteningOptions): Promise; /** * Retrieve and reconstruct a whitened CBL from a specific pool. * Both XOR component blocks are retrieved from the specified pool namespace. * * @param pool - The pool to retrieve the whitened CBL components from * @param blockId1 - First block ID (Checksum or hex string) * @param blockId2 - Second block ID (Checksum or hex string) * @param block1ParityIds - Optional parity block IDs for block 1 recovery * @param block2ParityIds - Optional parity block IDs for block 2 recovery * @returns The original CBL data as Uint8Array */ retrieveCBLFromPool(pool: PoolId, blockId1: Checksum | string, blockId2: Checksum | string, _block1ParityIds?: string[], _block2ParityIds?: string[]): Promise; has(key: Checksum | string): Promise; getData(key: Checksum): Promise; setData(block: RawDataBlock, options?: BlockStoreOptions): Promise; deleteData(key: Checksum): Promise; put(key: Checksum | string, data: Uint8Array, options?: BlockStoreOptions): Promise; delete(key: Checksum | string): Promise; get(key: Checksum | string): BlockHandle; getMetadata(key: Checksum | string): Promise; updateMetadata(key: Checksum | string, updates: Partial): Promise; clear(): void; size(): number; } //# sourceMappingURL=pooledMemoryBlockStore.d.ts.map