filecoin-pin
Version:
Bridge IPFS content to Filecoin Onchain Cloud using familiar tools
44 lines • 1.24 kB
TypeScript
/**
* Storage backend interface for CAR blockstore implementations.
* Allows platform-specific storage strategies (memory, filesystem, etc.)
*/
import type { CID } from 'multiformats/cid';
/**
* Offset information for a stored block
*/
export interface BlockOffset {
blockStart: number;
blockLength: number;
}
/**
* Result of backend initialization
*/
export interface InitializeResult {
headerSize: number;
}
/**
* Storage backend interface that handles platform-specific operations
*/
export interface CARStorageBackend {
/**
* Initialize the storage backend with a root CID
*/
initialize(rootCID: CID): Promise<InitializeResult>;
/**
* Write a block to storage at the calculated offset
*/
writeBlock(cid: CID, block: Uint8Array, offset: BlockOffset): Promise<void>;
/**
* Read a block from storage (optional - may throw if not supported)
*/
readBlock?(cid: CID, offset: BlockOffset): AsyncGenerator<Uint8Array>;
/**
* Finalize the storage (close streams, flush buffers, etc.)
*/
finalize(): Promise<void>;
/**
* Clean up resources (called on errors)
*/
cleanup(): Promise<void>;
}
//# sourceMappingURL=car-storage-backend.d.ts.map