diff options
| author | Jon Staab <jstaab@protonmail.com> | 2023-04-12 10:30:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-12 10:30:48 -0500 |
| commit | fb39455804cf772337616072a24dc5598ebefcbe (patch) | |
| tree | 1d0ea7337861703f4990ccaa0a56b0fd7d017008 | |
| parent | 4d8d66d6513a4270dd5d775c139b8e94885426ca (diff) | |
| parent | 9ef39553e464d1ecd656f57b615ce1aa72c39176 (diff) | |
Merge pull request #434 from CodyTseng/feat-improve-nip-45
feat: support counting by multiple filters
| -rw-r--r-- | 45.md | 18 |
1 files changed, 13 insertions, 5 deletions
| @@ -14,18 +14,26 @@ Some queries a client may want to execute against connected relays are prohibiti | |||
| 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 a filter as specified in [NIP 01](01.md). | 17 | This NIP defines a verb called `COUNT`, which accepts a subscription id and filters as specified in [NIP 01](01.md). |
| 18 | |||
| 19 | ``` | ||
| 20 | ["COUNT", <subscription_id>, <filters JSON>...] | ||
| 21 | ``` | ||
| 18 | 22 | ||
| 19 | 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. |
| 20 | 24 | ||
| 25 | ``` | ||
| 26 | ["COUNT", <subscription_id>, {"count": <integer>}] | ||
| 27 | ``` | ||
| 28 | |||
| 21 | Examples: | 29 | Examples: |
| 22 | 30 | ||
| 23 | ``` | 31 | ``` |
| 24 | # Followers count | 32 | # Followers count |
| 25 | ["COUNT", "", {kinds: [3], '#p': [<pubkey>]}] | 33 | ["COUNT", <subscription_id>, {"kinds": [3], "#p": [<pubkey>]}] |
| 26 | ["COUNT", "", {count: 238}] | 34 | ["COUNT", <subscription_id>, {"count": 238}] |
| 27 | 35 | ||
| 28 | # Count posts and reactions | 36 | # Count posts and reactions |
| 29 | ["COUNT", "", {kinds: [1, 7], authors: [<pubkey>]}] | 37 | ["COUNT", <subscription_id>, {"kinds": [1, 7], "authors": [<pubkey>]}] |
| 30 | ["COUNT", "", {count: 5}] | 38 | ["COUNT", <subscription_id>, {"count": 5}] |
| 31 | ``` | 39 | ``` |