diff --git a/packages/app/src/system.ts b/packages/app/src/system.ts index d7b70f30..e9f851ad 100644 --- a/packages/app/src/system.ts +++ b/packages/app/src/system.ts @@ -1,5 +1,6 @@ import { removeUndefined, throwIfOffline } from "@snort/shared"; import { mapEventToProfile, NostrEvent, NostrSystem, ProfileLoaderService, socialGraphInstance } from "@snort/system"; +import inMemoryDB from "@snort/system/src/InMemoryDB"; import { EventsCache, Relay, RelayMetrics, SystemDb, UserCache, UserRelays } from "@/Cache"; import { LoginStore } from "@/Utils/Login"; @@ -29,6 +30,7 @@ System.on("event", (_, ev) => { Relay.event(ev); EventsCache.discover(ev); UserCache.discover(ev); + inMemoryDB.handleEvent(ev); socialGraphInstance.handleEvent(ev); }); diff --git a/packages/system/src/connection.ts b/packages/system/src/connection.ts index b98c63b4..63d3b04f 100644 --- a/packages/system/src/connection.ts +++ b/packages/system/src/connection.ts @@ -10,8 +10,6 @@ import { NostrEvent, ReqCommand, ReqFilter, TaggedNostrEvent, u256 } from "./nos import { RelayInfo } from "./relay-info"; import EventKind from "./event-kind"; import { EventExt } from "./event-ext"; -import { getHex64 } from "./utils"; -import inMemoryDB from "./InMemoryDB"; /** * Relay settings @@ -203,21 +201,6 @@ export class Connection extends EventEmitter { OnMessage(e: WebSocket.MessageEvent) { this.#activity = unixNowMs(); if ((e.data as string).length > 0) { - // skip message processing if we've already seen it - /* there's some problem in retrieval from inMemoryDB? try disabling for now - const msgId = getHex64(e.data as string, "id"); - if (inMemoryDB.has(msgId)) { - console.log("already have"); - return; - } - */ - - const id = getHex64(e.data as string, "id"); - if (inMemoryDB.has(id)) { - this.#log("Already have, skip processing %s", id); - return; - } - const msg = JSON.parse(e.data as string) as Array; const tag = msg[0] as string; switch (tag) { diff --git a/packages/system/src/nostr-system.ts b/packages/system/src/nostr-system.ts index 279b9de3..ab271fd2 100644 --- a/packages/system/src/nostr-system.ts +++ b/packages/system/src/nostr-system.ts @@ -24,7 +24,6 @@ import { RelayMetadataLoader } from "./outbox-model"; import { Optimizer, DefaultOptimizer } from "./query-optimizer"; import { ConnectionPool, DefaultConnectionPool } from "./connection-pool"; import { QueryManager } from "./query-manager"; -import inMemoryDB from "./InMemoryDB"; export interface NostrSystemEvents { change: (state: SystemSnapshot) => void; @@ -123,7 +122,6 @@ export class NostrSystem extends EventEmitter implements Syst this.pool.on("event", (_, sub, ev) => { ev.relays?.length && this.relayMetricsHandler.onEvent(ev.relays[0]); this.emit("event", sub, ev); - inMemoryDB.handleEvent(ev); }); this.pool.on("disconnect", (id, code) => { const c = this.pool.getConnection(id); @@ -192,7 +190,6 @@ export class NostrSystem extends EventEmitter implements Syst } HandleEvent(subId: string, ev: TaggedNostrEvent) { - inMemoryDB.handleEvent(ev); this.emit("event", subId, ev); this.#queryManager.handleEvent(ev); }