use InMemoryDB instead of seenEvents LRUSet

This commit is contained in:
Martti Malmi
2024-01-05 12:04:52 +02:00
parent 29a8db28dd
commit 1a9e571b0f
6 changed files with 236 additions and 22 deletions

View File

@ -9,8 +9,8 @@ import { ConnectionStats } from "./connection-stats";
import { NostrEvent, ReqCommand, ReqFilter, TaggedNostrEvent, u256 } from "./nostr";
import { RelayInfo } from "./relay-info";
import EventKind from "./event-kind";
import { seenEvents } from "./seen-events";
import { getHex64 } from "./utils";
import inMemoryDB from "@snort/app/src/Cache/InMemoryDB";
/**
* Relay settings
@ -203,12 +203,10 @@ export class Connection extends EventEmitter<ConnectionEvents> {
if ((e.data as string).length > 0) {
// skip message processing if we've already seen it
const msgId = getHex64(e.data as string, "id");
/* Disabled in absence of local db
if (seenEvents.has(msgId)) {
if (inMemoryDB.has(msgId)) {
console.log('already have');
return;
}
*/
seenEvents.add(msgId); // TODO only do after msg validation
const msg = JSON.parse(e.data as string) as Array<string | NostrEvent | boolean>;
const tag = msg[0] as string;

View File

@ -33,7 +33,6 @@ export * from "./query-optimizer";
export * from "./encrypted";
export * from "./outbox-model";
export { parseIMeta } from "./utils";
export * from "./seen-events";
export * from "./impl/nip4";
export * from "./impl/nip44";

View File

@ -1,3 +0,0 @@
import LRUSet from "@snort/shared/src/LRUSet";
export const seenEvents = new LRUSet<string>(2000);