Add supportedNips to all storages

This commit is contained in:
Alex Gleason
2024-01-03 21:39:54 -06:00
parent 8ab0fefbf2
commit a4bc951eee
6 changed files with 13 additions and 5 deletions

View File

@@ -56,6 +56,9 @@ class EventsDB implements EventStore {
#db: Kysely<DittoDB>;
#debug = Debug('ditto:db:events');
/** NIPs supported by this storage method. */
supportedNips = [1, 45, 50];
constructor(db: Kysely<DittoDB>) {
this.#db = db;
}

View File

@@ -8,15 +8,13 @@ class Memorelay implements EventStore {
#debug = Debug('ditto:memorelay');
#cache: LRUCache<string, Event>;
/** NIPs supported by this storage method. */
supportedNips = [1, 45];
constructor(...args: ConstructorParameters<typeof LRUCache<string, Event>>) {
this.#cache = new LRUCache<string, Event>(...args);
}
/** NIPs supported by this storage method. */
get supportedNips(): number[] {
return [1];
}
/** Iterate stored events. */
*#events(): Generator<Event> {
for (const event of this.#cache.values()) {

View File

@@ -13,6 +13,8 @@ class Optimizer implements EventStore {
#cache: EventStore;
#client: EventStore;
supportedNips = [1];
constructor(opts: OptimizerOpts) {
this.#db = opts.db;
this.#cache = opts.cache;