UNPKG

filecoin-pin

Version:

Bridge IPFS content to Filecoin Onchain Cloud using familiar tools

51 lines 2.13 kB
/** * Shared base class for CAR blockstore implementations. * Contains all platform-agnostic blockstore logic. */ import type { Blockstore, InputPair, Pair } from 'interface-blockstore'; import type { AbortOptions, AwaitIterable } from 'interface-store'; import { CID } from 'multiformats/cid'; import type { BlockOffset, CARStorageBackend } from './car-storage-backend.js'; /** * Statistics about CAR blockstore operations */ export interface CARBlockstoreStats { blocksWritten: number; missingBlocks: Set<string>; totalSize: number; startTime: number; finalized: boolean; } /** * Optional event emitter for blockstore events */ export interface BlockstoreEvents { emit(event: string, ...args: any[]): void; } /** * Base CAR blockstore with pluggable storage backend */ export declare abstract class CARBlockstoreBase implements Blockstore { protected readonly rootCID: CID; protected readonly backend: CARStorageBackend; protected readonly blockOffsets: Map<string, BlockOffset>; protected readonly stats: CARBlockstoreStats; protected readonly events: BlockstoreEvents | undefined; protected currentOffset: number; protected finalized: boolean; protected initialized: boolean; constructor(rootCID: CID, backend: CARStorageBackend, events?: BlockstoreEvents); initialize(): Promise<void>; put(cid: CID, block: Uint8Array, _options?: AbortOptions): Promise<CID>; get(cid: CID, options?: AbortOptions): AsyncGenerator<Uint8Array>; has(cid: CID, _options?: AbortOptions): Promise<boolean>; delete(_cid: CID, _options?: AbortOptions): Promise<void>; putMany(source: AwaitIterable<InputPair>, _options?: AbortOptions): AsyncGenerator<CID>; getMany(source: AwaitIterable<CID>, options?: AbortOptions): AsyncGenerator<Pair>; deleteMany(_source: AwaitIterable<CID>, _options?: AbortOptions): AsyncGenerator<CID>; getAll(options?: AbortOptions): AsyncGenerator<Pair>; finalize(): Promise<CARBlockstoreStats>; getStats(): CARBlockstoreStats; cleanup(): Promise<void>; } //# sourceMappingURL=car-blockstore-base.d.ts.map