Add `supportedNips` to all storages
This commit is contained in:
parent
8ab0fefbf2
commit
a4bc951eee
|
@ -59,6 +59,7 @@ function storeEvent(event: Event, opts: StoreEventOpts = {}): Promise<void> {
|
|||
}
|
||||
|
||||
const client: EventStore = {
|
||||
supportedNips: [1],
|
||||
getEvents,
|
||||
storeEvent,
|
||||
countEvents: () => Promise.reject(new Error('COUNT not implemented')),
|
||||
|
|
|
@ -32,6 +32,8 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: Event) => an
|
|||
#promise!: Promise<void>;
|
||||
#resolve!: () => void;
|
||||
|
||||
supportedNips = [];
|
||||
|
||||
constructor(opts: ReqmeisterOpts = {}) {
|
||||
super();
|
||||
this.#opts = opts;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -33,6 +33,8 @@ interface DittoEvent<K extends number = number> extends Event<K> {
|
|||
|
||||
/** Storage interface for Nostr events. */
|
||||
interface EventStore {
|
||||
/** Indicates NIPs supported by this data store, similar to NIP-11. For example, `50` would indicate support for `search` filters. */
|
||||
supportedNips: readonly number[];
|
||||
/** Add an event to the store. */
|
||||
storeEvent(event: Event, opts?: StoreEventOpts): Promise<void>;
|
||||
/** Get events from filters. */
|
||||
|
|
Loading…
Reference in New Issue