import { CID } from 'multiformats';
/**
 * Mock implementation for the Blockstore interface.
 *
 * WARNING!!! Purely to be used with `ipfs-unixfs-importer` to compute CID without needing consume any memory.
 * This is particularly useful when dealing with large files and a necessity in a large-scale production service environment.
 */
export class BlockstoreMock {
    async open() {
    }
    async close() {
    }
    async put(key, _val, _options) {
        return key;
    }
    async get(_key, _options) {
        return new Uint8Array();
    }
    async has(_key, _options) {
        return false;
    }
    async delete(_key, _options) {
    }
    async isEmpty(_options) {
        return true;
    }
    async *putMany(source, options) {
        for await (const entry of source) {
            await this.put(entry.cid, entry.block, options);
            yield entry.cid;
        }
    }
    async *getMany(source, options) {
        for await (const key of source) {
            yield {
                cid: key,
                block: await this.get(key, options)
            };
        }
    }
    async *getAll(options) {
        // @ts-expect-error keyEncoding is 'buffer' but types for db.iterator always return the key type as 'string'
        const li = this.db.iterator({
            keys: true,
            keyEncoding: 'buffer'
        }, options);
        for await (const [key, value] of li) {
            yield { cid: CID.decode(key), block: value };
        }
    }
    async *deleteMany(source, options) {
        for await (const key of source) {
            await this.delete(key, options);
            yield key;
        }
    }
    /**
     * deletes all entries
     */
    async clear() {
    }
}
//# sourceMappingURL=blockstore-mock.js.map