diff options
| author | Pablo Fernandez <p@f7z.io> | 2023-11-23 17:52:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-23 17:52:48 +0200 |
| commit | 60256a62675a165c4d4fd9811a19a9cbf6a9e7fd (patch) | |
| tree | 5c450154d373caafc37f324dd01e20338308c9d6 /45.md | |
| parent | 43d50ee42409252a1313928cd437d55fd7bf7bf4 (diff) | |
| parent | 7822a8b12670312aff104ddc03066425882f739d (diff) | |
Merge branch 'master' into nip88
Diffstat (limited to '45.md')
| -rw-r--r-- | 45.md | 23 |
1 files changed, 15 insertions, 8 deletions
| @@ -4,7 +4,7 @@ NIP-45 | |||
| 4 | Event Counts | 4 | Event Counts |
| 5 | -------------- | 5 | -------------- |
| 6 | 6 | ||
| 7 | `draft` `optional` `author:staab` | 7 | `draft` `optional` |
| 8 | 8 | ||
| 9 | Relays may support the verb `COUNT`, 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 | ||
| @@ -16,29 +16,36 @@ Some queries a client may want to execute against connected relays are prohibiti | |||
| 16 | 16 | ||
| 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. | 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 | ```json |
| 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 | In case a relay uses probabilistic counts, it MAY indicate it in the response with `approximate` key i.e. `{"count": <integer>, "approximate": <true|false>}`. | 24 | In case a relay uses probabilistic counts, it MAY indicate it in the response with `approximate` key i.e. `{"count": <integer>, "approximate": <true|false>}`. |
| 25 | 25 | ||
| 26 | ``` | 26 | ```json |
| 27 | ["COUNT", <subscription_id>, {"count": <integer>}] | 27 | ["COUNT", <subscription_id>, {"count": <integer>}] |
| 28 | ``` | 28 | ``` |
| 29 | 29 | ||
| 30 | Examples: | 30 | ## Examples: |
| 31 | 31 | ||
| 32 | ``` | 32 | ### Followers count |
| 33 | # Followers count | 33 | |
| 34 | ```json | ||
| 34 | ["COUNT", <subscription_id>, {"kinds": [3], "#p": [<pubkey>]}] | 35 | ["COUNT", <subscription_id>, {"kinds": [3], "#p": [<pubkey>]}] |
| 35 | ["COUNT", <subscription_id>, {"count": 238}] | 36 | ["COUNT", <subscription_id>, {"count": 238}] |
| 37 | ``` | ||
| 36 | 38 | ||
| 37 | # Count posts and reactions | 39 | ### Count posts and reactions |
| 40 | |||
| 41 | ```json | ||
| 38 | ["COUNT", <subscription_id>, {"kinds": [1, 7], "authors": [<pubkey>]}] | 42 | ["COUNT", <subscription_id>, {"kinds": [1, 7], "authors": [<pubkey>]}] |
| 39 | ["COUNT", <subscription_id>, {"count": 5}] | 43 | ["COUNT", <subscription_id>, {"count": 5}] |
| 44 | ``` | ||
| 40 | 45 | ||
| 41 | # Count posts approximately | 46 | ### Count posts approximately |
| 47 | |||
| 48 | ``` | ||
| 42 | ["COUNT", <subscription_id>, {"kinds": [1]}] | 49 | ["COUNT", <subscription_id>, {"kinds": [1]}] |
| 43 | ["COUNT", <subscription_id>, {"count": 93412452, "approximate": true}] | 50 | ["COUNT", <subscription_id>, {"count": 93412452, "approximate": true}] |
| 44 | ``` | 51 | ``` |