rm redundant Events.seen

This commit is contained in:
Martti Malmi 2023-08-19 15:12:21 +03:00
parent 4f835d5080
commit 2534462b4d
3 changed files with 7 additions and 10 deletions

View File

@ -34,7 +34,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
releaseName: 'App v__VERSION__' releaseName: 'Iris v__VERSION__'
releaseBody: 'See the assets to download this version and install.' releaseBody: 'See the assets to download this version and install.'
releaseDraft: true releaseDraft: true
prerelease: false prerelease: false

View File

@ -19,7 +19,7 @@ import {
getRepostedEventId, getRepostedEventId,
isRepost, isRepost,
} from '@/nostr/utils.ts'; } from '@/nostr/utils.ts';
import { ID, STR, UID, UniqueIds } from '@/utils/UniqueIds.ts'; import { ID, STR, UniqueIds } from '@/utils/UniqueIds.ts';
import localState from '../LocalState'; import localState from '../LocalState';
import { Node } from '../LocalState'; import { Node } from '../LocalState';
@ -65,7 +65,6 @@ const Events = {
DEFAULT_GLOBAL_FILTER, DEFAULT_GLOBAL_FILTER,
getEventHash, getEventHash,
eventsMetaDb: new EventMetaStore(), eventsMetaDb: new EventMetaStore(),
seen: new Set<UID>(),
deletedEvents: new Set<string>(), deletedEvents: new Set<string>(),
latestNotificationByTargetAndKind: new Map<string, string>(), latestNotificationByTargetAndKind: new Map<string, string>(),
notifications: new SortedLimitedEventSet(MAX_LATEST_MSGS), notifications: new SortedLimitedEventSet(MAX_LATEST_MSGS),
@ -440,11 +439,11 @@ const Events = {
return true; return true;
}, },
handle(event: Event & { id: string }, force = false, saveToIdb = true, retries = 2): boolean { handle(event: Event & { id: string }, force = false, saveToIdb = true, retries = 2): boolean {
if (!event) return false; if (!event?.id) return false;
const id = ID(event.id); if (!force && UniqueIds.has(event.id)) {
if (!force && this.seen.has(id)) {
return false; return false;
} }
ID(event.id); // add to UniqueIds
if (!force && !this.acceptEvent(event)) { if (!force && !this.acceptEvent(event)) {
if (retries) { if (retries) {
// should we retry only if iris has been opened within the last few seconds or the social graph changed? // should we retry only if iris has been opened within the last few seconds or the social graph changed?
@ -481,8 +480,6 @@ const Events = {
return false; return false;
} }
this.seen.add(id);
this.handledMsgsPerSecond++; this.handledMsgsPerSecond++;
PubSub.subscribedEventIds.delete(event.id); PubSub.subscribedEventIds.delete(event.id);

View File

@ -6,7 +6,7 @@ import Filter from '@/nostr/Filter';
const { authenticate } = nip42; const { authenticate } = nip42;
import EventDB from '@/nostr/EventDB.ts'; import EventDB from '@/nostr/EventDB.ts';
import { ID } from '@/utils/UniqueIds.ts'; import { UniqueIds } from '@/utils/UniqueIds.ts';
import localState from '../LocalState'; import localState from '../LocalState';
import Events from '../nostr/Events'; import Events from '../nostr/Events';
@ -26,7 +26,7 @@ const relayPool = new RelayPool(Relays.enabledRelays(), {
autoReconnect: true, autoReconnect: true,
externalGetEventById: (id) => { externalGetEventById: (id) => {
return ( return (
(Events.seen.has(ID(id)) && { (UniqueIds.has(id) && {
sig: '', sig: '',
id: '', id: '',
kind: 0, kind: 0,