import type { Key, Range } from '../interfaces/common.js'; import type { AztecAsyncSet } from '../interfaces/set.js'; import { LMDBMap } from './map.js'; import type { AztecLMDBStoreV2 } from './store.js'; /** * A set backed by LMDB. */ export class LMDBSet implements AztecAsyncSet { private map: LMDBMap; constructor(store: AztecLMDBStoreV2, mapName: string) { this.map = new LMDBMap(store, mapName); } hasAsync(key: K): Promise { return this.map.hasAsync(key); } add(key: K): Promise { return this.map.set(key, true); } delete(key: K): Promise { return this.map.delete(key); } async *entriesAsync(range: Range = {}): AsyncIterableIterator { for await (const key of this.map.keysAsync(range)) { yield key; } } }