mirror of
https://github.com/nostr-protocol/nips.git
synced 2025-12-09 00:28:51 +00:00
Add NIP-45, which defines a COUNT verb
This commit is contained in:
31
45.md
Normal file
31
45.md
Normal file
@@ -0,0 +1,31 @@
|
||||
NIP-45
|
||||
======
|
||||
|
||||
Event Counts
|
||||
--------------
|
||||
|
||||
`draft` `optional` `author:staab`
|
||||
|
||||
Relays may support the `COUNT` verb, which provide a mechanism for obtaining event counts.
|
||||
|
||||
## Motivation
|
||||
|
||||
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.
|
||||
|
||||
## 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).
|
||||
|
||||
Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements.
|
||||
|
||||
Examples:
|
||||
|
||||
```
|
||||
# Followers count
|
||||
["COUNT", "", {kinds: [3], '#p': [<pubkey>]}]
|
||||
["COUNT", "", {count: 238}]
|
||||
|
||||
# Count posts and reactions
|
||||
["COUNT", "", {kinds: [1, 7], authors: [<pubkey>]}]
|
||||
["COUNT", "", {count: 5}]
|
||||
```
|
||||
Reference in New Issue
Block a user