mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Add supportedNips to all storages
This commit is contained in:
parent
8ab0fefbf2
commit
a4bc951eee
6 changed files with 13 additions and 5 deletions
|
|
@ -59,6 +59,7 @@ function storeEvent(event: Event, opts: StoreEventOpts = {}): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const client: EventStore = {
|
const client: EventStore = {
|
||||||
|
supportedNips: [1],
|
||||||
getEvents,
|
getEvents,
|
||||||
storeEvent,
|
storeEvent,
|
||||||
countEvents: () => Promise.reject(new Error('COUNT not implemented')),
|
countEvents: () => Promise.reject(new Error('COUNT not implemented')),
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: Event) => an
|
||||||
#promise!: Promise<void>;
|
#promise!: Promise<void>;
|
||||||
#resolve!: () => void;
|
#resolve!: () => void;
|
||||||
|
|
||||||
|
supportedNips = [];
|
||||||
|
|
||||||
constructor(opts: ReqmeisterOpts = {}) {
|
constructor(opts: ReqmeisterOpts = {}) {
|
||||||
super();
|
super();
|
||||||
this.#opts = opts;
|
this.#opts = opts;
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ class EventsDB implements EventStore {
|
||||||
#db: Kysely<DittoDB>;
|
#db: Kysely<DittoDB>;
|
||||||
#debug = Debug('ditto:db:events');
|
#debug = Debug('ditto:db:events');
|
||||||
|
|
||||||
|
/** NIPs supported by this storage method. */
|
||||||
|
supportedNips = [1, 45, 50];
|
||||||
|
|
||||||
constructor(db: Kysely<DittoDB>) {
|
constructor(db: Kysely<DittoDB>) {
|
||||||
this.#db = db;
|
this.#db = db;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,13 @@ class Memorelay implements EventStore {
|
||||||
#debug = Debug('ditto:memorelay');
|
#debug = Debug('ditto:memorelay');
|
||||||
#cache: LRUCache<string, Event>;
|
#cache: LRUCache<string, Event>;
|
||||||
|
|
||||||
|
/** NIPs supported by this storage method. */
|
||||||
|
supportedNips = [1, 45];
|
||||||
|
|
||||||
constructor(...args: ConstructorParameters<typeof LRUCache<string, Event>>) {
|
constructor(...args: ConstructorParameters<typeof LRUCache<string, Event>>) {
|
||||||
this.#cache = new LRUCache<string, Event>(...args);
|
this.#cache = new LRUCache<string, Event>(...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** NIPs supported by this storage method. */
|
|
||||||
get supportedNips(): number[] {
|
|
||||||
return [1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Iterate stored events. */
|
/** Iterate stored events. */
|
||||||
*#events(): Generator<Event> {
|
*#events(): Generator<Event> {
|
||||||
for (const event of this.#cache.values()) {
|
for (const event of this.#cache.values()) {
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ class Optimizer implements EventStore {
|
||||||
#cache: EventStore;
|
#cache: EventStore;
|
||||||
#client: EventStore;
|
#client: EventStore;
|
||||||
|
|
||||||
|
supportedNips = [1];
|
||||||
|
|
||||||
constructor(opts: OptimizerOpts) {
|
constructor(opts: OptimizerOpts) {
|
||||||
this.#db = opts.db;
|
this.#db = opts.db;
|
||||||
this.#cache = opts.cache;
|
this.#cache = opts.cache;
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ interface DittoEvent<K extends number = number> extends Event<K> {
|
||||||
|
|
||||||
/** Storage interface for Nostr events. */
|
/** Storage interface for Nostr events. */
|
||||||
interface EventStore {
|
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. */
|
/** Add an event to the store. */
|
||||||
storeEvent(event: Event, opts?: StoreEventOpts): Promise<void>;
|
storeEvent(event: Event, opts?: StoreEventOpts): Promise<void>;
|
||||||
/** Get events from filters. */
|
/** Get events from filters. */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue