fix: deliver events to every matching subscription on a connection
notify_event returned after the first filter that matched, so a connection holding several subscriptions only ever received an event on one of them. That is invisible with one subscription per client, but a multiplexer such as nostrclient funnels all of its clients through a single connection. With nwcprovider subscribed to its own kind-23195 responses, every NWC reply was handed to that subscription and stopped there; the wallet app's subscription on the same connection never saw it, and Amethyst reported "wallet request timed out". Direct to the relay it worked, because the app then had its own connection. Deliver once per subscription id instead, and demote the per-filter miss log to debug: it emitted one INFO line per filter per event. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013Tbyw6FwjhEJg3gHfPHxWt
This commit is contained in:
parent
4811fcf352
commit
4fec1dc826
2 changed files with 95 additions and 5 deletions
|
|
@ -72,16 +72,24 @@ class NostrClientConnection:
|
|||
if self._is_private_event_for_other(event):
|
||||
return False
|
||||
|
||||
# One connection can hold several subscriptions whose filters all match
|
||||
# the same event: a multiplexer such as nostrclient funnels every one of
|
||||
# its clients through a single connection. NIP-01 requires the event to
|
||||
# reach each matching subscription, so deliver once per subscription id
|
||||
# rather than stopping at the first hit.
|
||||
notified: set[str] = set()
|
||||
for nostr_filter in self.filters:
|
||||
sub_id = nostr_filter.subscription_id
|
||||
if sub_id in notified:
|
||||
continue
|
||||
if nostr_filter.matches(event):
|
||||
resp = event.serialize_response(nostr_filter.subscription_id)
|
||||
await self._send_msg(resp)
|
||||
return True
|
||||
notified.add(sub_id) # type: ignore[arg-type]
|
||||
await self._send_msg(event.serialize_response(sub_id))
|
||||
else:
|
||||
logger.info(
|
||||
logger.debug(
|
||||
f"[NOSTRRELAY CLIENT] ❌ Filter didn't match for event {event.id}"
|
||||
)
|
||||
return False
|
||||
return len(notified) > 0
|
||||
|
||||
def _is_private_event_for_other(self, event: NostrEvent) -> bool:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue