nips icon indicating copy to clipboard operation
nips copied to clipboard

NIP-01: `limit` in multiple filters

Open schmijos opened this issue 11 months ago • 4 comments

How should relays interpret the limit specification if present in multiple filters? There seem to be contradicting specs regarding the limit filter field if given by multiple filters

[
  {"limit": 2, …},
  {"limit": 40, …}
]
  1. NIP-01 specifies that we can use multiple filters in a subscription

A REQ message may contain multiple filters. In this case, events that match any of the filters are to be returned, i.e., multiple filters are to be interpreted as || conditions.

  1. NIP-01 also specifies that a limit determines the <maximum number of events relays SHOULD return in the initial query>

Is the limit to be applied for each filter? So we return 40-42 events depending on whether the matching events overlap. Or should the maximum limit of any given limit be relevant, since the idea is to clamp the event count of the initial query?

schmijos avatar Mar 09 '24 20:03 schmijos

Each filter has an independent limit. I often want to have a limit for all filters, so it seems like an oversight.

alexgleason avatar Mar 09 '24 20:03 alexgleason

Each filter has an independent limit. I often want to have a limit for all filters, so it seems like an oversight.

I want/need a limit for each kind within each filter :)

vitorpamplona avatar Mar 09 '24 20:03 vitorpamplona

Fortunately clients can just specify no limit and then disconnect whenever.

alexgleason avatar Mar 09 '24 20:03 alexgleason

👍 I try to make this a bit clearer in #1117

schmijos avatar Mar 10 '24 09:03 schmijos