From 2534462b4dfff6135a8cb1458945d66954e36811 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Sat, 19 Aug 2023 15:12:21 +0300 Subject: [PATCH] rm redundant Events.seen --- .github/workflows/tauri.yml | 2 +- src/js/nostr/Events.ts | 11 ++++------- src/js/nostr/PubSub.ts | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tauri.yml b/.github/workflows/tauri.yml index 506803af..cd329272 100644 --- a/.github/workflows/tauri.yml +++ b/.github/workflows/tauri.yml @@ -34,7 +34,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: 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.' releaseDraft: true prerelease: false \ No newline at end of file diff --git a/src/js/nostr/Events.ts b/src/js/nostr/Events.ts index 2caebea0..affa76d2 100644 --- a/src/js/nostr/Events.ts +++ b/src/js/nostr/Events.ts @@ -19,7 +19,7 @@ import { getRepostedEventId, isRepost, } 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 { Node } from '../LocalState'; @@ -65,7 +65,6 @@ const Events = { DEFAULT_GLOBAL_FILTER, getEventHash, eventsMetaDb: new EventMetaStore(), - seen: new Set(), deletedEvents: new Set(), latestNotificationByTargetAndKind: new Map(), notifications: new SortedLimitedEventSet(MAX_LATEST_MSGS), @@ -440,11 +439,11 @@ const Events = { return true; }, handle(event: Event & { id: string }, force = false, saveToIdb = true, retries = 2): boolean { - if (!event) return false; - const id = ID(event.id); - if (!force && this.seen.has(id)) { + if (!event?.id) return false; + if (!force && UniqueIds.has(event.id)) { return false; } + ID(event.id); // add to UniqueIds if (!force && !this.acceptEvent(event)) { if (retries) { // 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; } - this.seen.add(id); - this.handledMsgsPerSecond++; PubSub.subscribedEventIds.delete(event.id); diff --git a/src/js/nostr/PubSub.ts b/src/js/nostr/PubSub.ts index 5e65b3ba..e1b4b34f 100644 --- a/src/js/nostr/PubSub.ts +++ b/src/js/nostr/PubSub.ts @@ -6,7 +6,7 @@ import Filter from '@/nostr/Filter'; const { authenticate } = nip42; import EventDB from '@/nostr/EventDB.ts'; -import { ID } from '@/utils/UniqueIds.ts'; +import { UniqueIds } from '@/utils/UniqueIds.ts'; import localState from '../LocalState'; import Events from '../nostr/Events'; @@ -26,7 +26,7 @@ const relayPool = new RelayPool(Relays.enabledRelays(), { autoReconnect: true, externalGetEventById: (id) => { return ( - (Events.seen.has(ID(id)) && { + (UniqueIds.has(id) && { sig: '', id: '', kind: 0,