diff options
| author | Jon Staab <jstaab@protonmail.com> | 2023-05-06 11:35:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-06 15:35:21 -0300 |
| commit | d5484a33bcaf717ef1ef54a0f9be1b76c4f70afa (patch) | |
| tree | ff4264b6a9ccc1df258faedb5be7ef437430ce3f | |
| parent | bc9d469c203a25a706727219fa7d37dacaf6040d (diff) | |
Clarify how NIP 45 works with multiple COUNT filters. (#504)
| -rw-r--r-- | 45.md | 8 |
1 files changed, 4 insertions, 4 deletions
| @@ -6,21 +6,21 @@ Event Counts | |||
| 6 | 6 | ||
| 7 | `draft` `optional` `author:staab` | 7 | `draft` `optional` `author:staab` |
| 8 | 8 | ||
| 9 | Relays may support the `COUNT` verb, which provides a mechanism for obtaining event counts. | 9 | Relays may support the verb `COUNT`, which provides a mechanism for obtaining event counts. |
| 10 | 10 | ||
| 11 | ## Motivation | 11 | ## Motivation |
| 12 | 12 | ||
| 13 | Some queries a client may want to execute against connected relays are prohibitively expensive, for example, in order to retrieve follower counts for a given pubkey, a client must query all kind-3 events referring to a given pubkey and count them. The result may be cached, either by a client or by a separate indexing server as an alternative, but both options erode the decentralization of the network by creating a second-layer protocol on top of Nostr. | 13 | Some queries a client may want to execute against connected relays are prohibitively expensive, for example, in order to retrieve follower counts for a given pubkey, a client must query all kind-3 events referring to a given pubkey only to count them. The result may be cached, either by a client or by a separate indexing server as an alternative, but both options erode the decentralization of the network by creating a second-layer protocol on top of Nostr. |
| 14 | 14 | ||
| 15 | ## Filters and return values | 15 | ## Filters and return values |
| 16 | 16 | ||
| 17 | This NIP defines a verb called `COUNT`, which accepts a subscription id and filters as specified in [NIP 01](01.md). | 17 | This NIP defines the verb `COUNT`, which accepts a subscription id and filters as specified in [NIP 01](01.md) for the verb `REQ`. Multiple filters are OR'd together and aggregated into a single count result. |
| 18 | 18 | ||
| 19 | ``` | 19 | ``` |
| 20 | ["COUNT", <subscription_id>, <filters JSON>...] | 20 | ["COUNT", <subscription_id>, <filters JSON>...] |
| 21 | ``` | 21 | ``` |
| 22 | 22 | ||
| 23 | Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements. | 23 | Counts are returned using a `COUNT` response in the form `{"count": <integer>}`. Relays may use probabilistic counts to reduce compute requirements. |
| 24 | 24 | ||
| 25 | ``` | 25 | ``` |
| 26 | ["COUNT", <subscription_id>, {"count": <integer>}] | 26 | ["COUNT", <subscription_id>, {"count": <integer>}] |