forked from Kieran/snort
feat: system on-event
This commit is contained in:
parent
3326aedc52
commit
c9935a275e
@ -29,6 +29,7 @@ import { trimFilters } from "./request-trim";
|
|||||||
interface NostrSystemEvents {
|
interface NostrSystemEvents {
|
||||||
change: (state: SystemSnapshot) => void;
|
change: (state: SystemSnapshot) => void;
|
||||||
auth: (challenge: string, relay: string, cb: (ev: NostrEvent) => void) => void;
|
auth: (challenge: string, relay: string, cb: (ev: NostrEvent) => void) => void;
|
||||||
|
event: (ev: TaggedNostrEvent) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export declare interface NostrSystem {
|
export declare interface NostrSystem {
|
||||||
@ -193,6 +194,8 @@ export class NostrSystem extends EventEmitter implements SystemInterface {
|
|||||||
|
|
||||||
#onEvent(sub: string, ev: TaggedNostrEvent) {
|
#onEvent(sub: string, ev: TaggedNostrEvent) {
|
||||||
this.#relayMetrics.onEvent(ev.relays[0]);
|
this.#relayMetrics.onEvent(ev.relays[0]);
|
||||||
|
this.emit("event", ev);
|
||||||
|
|
||||||
if (!EventExt.isValid(ev)) {
|
if (!EventExt.isValid(ev)) {
|
||||||
this.#log("Rejecting invalid event %O", ev);
|
this.#log("Rejecting invalid event %O", ev);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user