mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-11-14 07:49:07 -05:00
Merge pull request #434 from CodyTseng/feat-improve-nip-45
feat: support counting by multiple filters
This commit is contained in:
commit
fb39455804
18
45.md
18
45.md
|
@ -14,18 +14,26 @@ Some queries a client may want to execute against connected relays are prohibiti
|
||||||
|
|
||||||
## Filters and return values
|
## Filters and return values
|
||||||
|
|
||||||
This NIP defines a verb called `COUNT`, which accepts a subscription id and a filter as specified in [NIP 01](01.md).
|
This NIP defines a verb called `COUNT`, which accepts a subscription id and filters as specified in [NIP 01](01.md).
|
||||||
|
|
||||||
|
```
|
||||||
|
["COUNT", <subscription_id>, <filters JSON>...]
|
||||||
|
```
|
||||||
|
|
||||||
Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements.
|
Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements.
|
||||||
|
|
||||||
|
```
|
||||||
|
["COUNT", <subscription_id>, {"count": <integer>}]
|
||||||
|
```
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
```
|
```
|
||||||
# Followers count
|
# Followers count
|
||||||
["COUNT", "", {kinds: [3], '#p': [<pubkey>]}]
|
["COUNT", <subscription_id>, {"kinds": [3], "#p": [<pubkey>]}]
|
||||||
["COUNT", "", {count: 238}]
|
["COUNT", <subscription_id>, {"count": 238}]
|
||||||
|
|
||||||
# Count posts and reactions
|
# Count posts and reactions
|
||||||
["COUNT", "", {kinds: [1, 7], authors: [<pubkey>]}]
|
["COUNT", <subscription_id>, {"kinds": [1, 7], "authors": [<pubkey>]}]
|
||||||
["COUNT", "", {count: 5}]
|
["COUNT", <subscription_id>, {"count": 5}]
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue
Block a user