use LRUSet to skip already seen event processing
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import Dexie, { Table } from "dexie";
|
||||
import { TaggedNostrEvent, ReqFilter as Filter } from "@snort/system";
|
||||
import * as Comlink from "comlink";
|
||||
import LRUSet from "@/Cache/LRUSet";
|
||||
import LRUSet from "@snort/shared/src/LRUSet";
|
||||
|
||||
type Tag = {
|
||||
id: string;
|
||||
|
@ -1,23 +0,0 @@
|
||||
export default class LRUSet<T> {
|
||||
private set = new Set<T>();
|
||||
private limit: number;
|
||||
|
||||
constructor(limit: number) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
add(item: T) {
|
||||
if (this.set.size >= this.limit) {
|
||||
this.set.delete(this.set.values().next().value);
|
||||
}
|
||||
this.set.add(item);
|
||||
}
|
||||
|
||||
has(item: T) {
|
||||
return this.set.has(item);
|
||||
}
|
||||
|
||||
values() {
|
||||
return this.set.values();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user