Fix marking events as seen in subscriptions when not matched

This commit is contained in:
Jon Staab
2024-11-11 11:45:03 -08:00
parent 2bc5565580
commit 76ad0ba976
5 changed files with 5 additions and 7 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/app", "name": "@welshman/app",
"version": "0.0.24", "version": "0.0.25",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "A collection of svelte stores for use in building nostr client applications.", "description": "A collection of svelte stores for use in building nostr client applications.",
+1 -1
View File
@@ -221,7 +221,7 @@ const onConnectionReceive = ({url, state}: Connection, [verb, ...extra]: Message
const onConnectionError = ({url}: Connection) => const onConnectionError = ({url}: Connection) =>
updateRelayStats([url, stats => { updateRelayStats([url, stats => {
stats.last_error = now() stats.last_error = now()
stats.recent_errors = stats.recent_errors.concat(now()).slice(-10) stats.recent_errors = uniq(stats.recent_errors.concat(now())).slice(-10)
}]) }])
export const trackRelayStats = (connection: Connection) => { export const trackRelayStats = (connection: Connection) => {
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/net", "name": "@welshman/net",
"version": "0.0.34", "version": "0.0.35",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
"description": "Utilities for connecting with nostr relays.", "description": "Utilities for connecting with nostr relays.",
+1 -3
View File
@@ -166,9 +166,7 @@ export const optimizeSubscriptions = (subs: Subscription[]) => {
mergedSub.emitter.on(SubscriptionEvent.Event, (url: string, event: TrustedEvent) => { mergedSub.emitter.on(SubscriptionEvent.Event, (url: string, event: TrustedEvent) => {
for (const sub of group) { for (const sub of group) {
const seen = sub.tracker.track(event.id, url) if (matchFilters(sub.request.filters, event) && !sub.tracker.track(event.id, url)) {
if (!seen && matchFilters(sub.request.filters, event)) {
sub.emitter.emit(SubscriptionEvent.Event, url, event) sub.emitter.emit(SubscriptionEvent.Event, url, event)
} }
} }
+1 -1
View File
@@ -220,7 +220,7 @@ export const getFilterGenerality = (filter: Filter) => {
} }
if (filter.authors) { if (filter.authors) {
return Math.min(1, filter.authors.length / 100) return Math.min(1, filter.authors.length / 300)
} }
return 1 return 1