import { Type } from "@chainsafe/ssz"; import { ChainForkConfig } from "@lodestar/config"; import { KeyValue } from "./controller/index.js"; import { Db, DbBatch, FilterOptions } from "./controller/interface.js"; type Id = Uint8Array | string | number | bigint; /** * Repository is a high level kv storage * This abstract repository is designed in a way to store items with different prefixed * Specially when those prefixed data is not available in the object to be stored * * By default, SSZ-encoded values, */ export declare abstract class PrefixedRepository { protected config: ChainForkConfig; protected db: Db; protected bucket: number; protected type: Type; private readonly bucketId; private readonly dbReqOpts; /** Inclusive range for the minimum key for the bucket */ private readonly minKey; /** Exclusive range for the maximum key for the bucket */ private readonly maxKey; protected constructor(config: ChainForkConfig, db: Db, bucket: number, type: Type, bucketId: string); abstract encodeKeyRaw(prefix: P, id: I): Uint8Array; abstract decodeKeyRaw(raw: Uint8Array): { prefix: P; id: I; }; /** * Max key is inclusive * */ abstract getMaxKeyRaw(prefix: P): Uint8Array; /** * Min key is inclusive * */ abstract getMinKeyRaw(prefix: P): Uint8Array; protected encodeValue(value: T): Uint8Array; protected decodeValue(data: Uint8Array): T; protected wrapKey(raw: Uint8Array): Uint8Array; protected unwrapKey(key: Uint8Array): Uint8Array; getId(value: T): I; get(prefix: P, id: I): Promise; getMany(prefix: P, ids: I[]): Promise<(T | undefined)[]>; getManyBinary(prefix: P, ids: I[]): Promise<(Uint8Array | undefined)[]>; getBinary(prefix: P, id: I): Promise; put(prefix: P, item: T): Promise; putMany(prefix: P, items: T[]): Promise; putBinary(prefix: P, id: I, bytes: Uint8Array): Promise; putManyBinary(prefix: P, items: KeyValue[]): Promise; delete(prefix: P, id: I): Promise; deleteMany(prefix: P | P[]): Promise; batch(prefix: P, batch: DbBatch): Promise; batchBinary(prefix: P, batch: DbBatch): Promise; values(prefix: P | P[]): Promise; valuesBinary(prefix: P | P[]): Promise; valuesStream(prefix: P | P[]): AsyncIterable; valuesStreamBinary(prefix: P | P[]): AsyncIterable<{ prefix: P; id: I; value: Uint8Array; }>; entriesStream(prefix: P | P[]): AsyncIterable<{ prefix: P; id: I; value: T; }>; entriesStreamBinary(prefix: P | P[]): AsyncIterable<{ prefix: P; id: I; value: Uint8Array; }>; keys(opts?: FilterOptions<{ prefix: P; id: I; }>): Promise<{ prefix: P; id: I; }[]>; } export {}; //# sourceMappingURL=abstractPrefixedRepository.d.ts.map