Reqmeister: encounter -> storeEvent
This commit is contained in:
parent
a10108e109
commit
f8a0698c3a
|
@ -43,7 +43,7 @@ async function handleEvent(event: Event): Promise<void> {
|
||||||
async function encounterEvent(event: Event): Promise<boolean> {
|
async function encounterEvent(event: Event): Promise<boolean> {
|
||||||
const preexisting = (await memorelay.countEvents([{ ids: [event.id] }])) > 0;
|
const preexisting = (await memorelay.countEvents([{ ids: [event.id] }])) > 0;
|
||||||
memorelay.storeEvent(event);
|
memorelay.storeEvent(event);
|
||||||
reqmeister.encounter(event);
|
reqmeister.storeEvent(event);
|
||||||
return preexisting;
|
return preexisting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: Event) => an
|
||||||
const events = await client.getEvents(filters, { signal: AbortSignal.timeout(timeout) });
|
const events = await client.getEvents(filters, { signal: AbortSignal.timeout(timeout) });
|
||||||
|
|
||||||
for (const event of events) {
|
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));
|
const filterId = getFilterId(eventToMicroFilter(event));
|
||||||
this.#queue = this.#queue.filter(([id]) => id !== filterId);
|
this.#queue = this.#queue.filter(([id]) => id !== filterId);
|
||||||
this.emit(filterId, event);
|
this.emit(filterId, event);
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
isWanted(event: Event): boolean {
|
isWanted(event: Event): boolean {
|
||||||
|
@ -144,11 +145,6 @@ class Reqmeister extends EventEmitter<{ [filterId: string]: (event: Event) => an
|
||||||
return Promise.all(promises);
|
return Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
storeEvent(event: Event): Promise<void> {
|
|
||||||
this.encounter(event);
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
countEvents(_filters: Filter[]): Promise<number> {
|
countEvents(_filters: Filter[]): Promise<number> {
|
||||||
throw new Error('COUNT not implemented.');
|
throw new Error('COUNT not implemented.');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue