diff --git a/packages/app/src/system.ts b/packages/app/src/system.ts index 7ced2bfb..a694716f 100644 --- a/packages/app/src/system.ts +++ b/packages/app/src/system.ts @@ -4,19 +4,14 @@ import { NostrEvent, NostrSystem, ProfileLoaderService, - ReqFilter, socialGraphInstance, - TaggedNostrEvent, } from "@snort/system"; -import * as Comlink from "comlink"; import { RelayMetrics, SystemDb, UserCache, UserRelays } from "@/Cache"; import { addEventToFuzzySearch } from "@/Db/FuzzySearch"; -import IndexedDBWorker from "@/Db/IndexedDB?worker"; import { LoginStore } from "@/Utils/Login"; import { hasWasm, WasmOptimizer } from "@/Utils/wasm"; -export const indexedDB = Comlink.wrap(new IndexedDBWorker()); /** * Singleton nostr system */ @@ -39,30 +34,8 @@ System.on("auth", async (c, r, cb) => { System.on("event", (_, ev) => { addEventToFuzzySearch(ev); socialGraphInstance.handleEvent(ev); - if (CONFIG.useIndexedDBEvents && socialGraphInstance.getFollowDistance(ev.pubkey) <= 2) { - indexedDB.handleEvent(ev); - } }); -System.on("request", (filter: ReqFilter) => { - if (CONFIG.useIndexedDBEvents) { - indexedDB.find( - filter, - Comlink.proxy((e: TaggedNostrEvent) => { - System.HandleEvent(e); - }), - ); - } -}); - -if (CONFIG.useIndexedDBEvents) { - // load all profiles - indexedDB.find( - { kinds: [0] }, - Comlink.proxy((e: TaggedNostrEvent) => System.HandleEvent(e)), - ); -} - /** * Add profile loader fn */ diff --git a/packages/system/src/nostr-system.ts b/packages/system/src/nostr-system.ts index 9828f35e..add130a6 100644 --- a/packages/system/src/nostr-system.ts +++ b/packages/system/src/nostr-system.ts @@ -26,7 +26,6 @@ import { RelayCache, RelayMetadataLoader } from "./outbox-model"; import { Optimizer, DefaultOptimizer } from "./query-optimizer"; import { trimFilters } from "./request-trim"; import { NostrConnectionPool } from "./nostr-connection-pool"; -import inMemoryDB from "./InMemoryDB"; export interface NostrSystemEvents { change: (state: SystemSnapshot) => void; @@ -168,7 +167,6 @@ export class NostrSystem extends EventEmitter implements Syst // internal handler for on-event this.on("event", (sub, ev) => { - inMemoryDB.handleEvent(ev); for (const [, v] of this.Queries) { v.handleEvent(sub, ev); } @@ -318,22 +316,6 @@ export class NostrSystem extends EventEmitter implements Syst } qSend.filters = fNew; - fNew.forEach(f => { - const alreadyHave = inMemoryDB.findArray(f).map(e => { - this.HandleEvent(e); - return e.id; - }); - if (alreadyHave.length) { - f.not = f.not ?? {}; - if (f.not.ids) { - f.not.ids.push(...alreadyHave); - } else { - f.not.ids = alreadyHave; - } - } - this.emit("request", f); - }); - if (qSend.relay) { this.#log("Sending query to %s %O", qSend.relay, qSend); const s = this.#pool.getConnection(qSend.relay);