Reqmeister: encounter -> storeEvent

This commit is contained in:
Alex Gleason 2024-01-07 16:37:06 -06:00
parent a10108e109
commit f8a0698c3a
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 4 additions and 8 deletions

View File

@ -43,7 +43,7 @@ async function handleEvent(event: Event): Promise<void> {
async function encounterEvent(event: Event): Promise<boolean> {
const preexisting = (await memorelay.countEvents([{ ids: [event.id] }])) > 0;
memorelay.storeEvent(event);
reqmeister.encounter(event);
reqmeister.storeEvent(event);
return preexisting;
}

View File

@ -77,7 +77,7 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: Event) => an
const events = await client.getEvents(filters, { signal: AbortSignal.timeout(timeout) });
for (const event of events) {
this.encounter(event);
this.storeEvent(event);
}
}
@ -119,10 +119,11 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: Event) => an
});
}
encounter(event: Event): void {
storeEvent(event: Event): Promise<void> {
const filterId = getFilterId(eventToMicroFilter(event));
this.#queue = this.#queue.filter(([id]) => id !== filterId);
this.emit(filterId, event);
return Promise.resolve();
}
isWanted(event: Event): boolean {
@ -144,11 +145,6 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: Event) => an
return Promise.all(promises);
}
storeEvent(event: Event): Promise<void> {
this.encounter(event);
return Promise.resolve();
}
countEvents(_filters: Filter[]): Promise<number> {
throw new Error('COUNT not implemented.');
}