upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/45.md
diff options
context:
space:
mode:
authorJonathan Staab <shtaab@gmail.com>2023-01-03 20:11:17 -0800
committerfiatjaf <fiatjaf@gmail.com>2023-04-05 18:41:14 -0300
commite219ec64701d89e6b2c3f3ca8fd426d0aefdcb9c (patch)
tree43dc4d0d6d4bd01dd239f0141bbdae802526f873 /45.md
parent45e6af1ad9d10e66417c07b995e497171653f0c1 (diff)
Add NIP-45, which defines a COUNT verb
Diffstat (limited to '45.md')
-rw-r--r--45.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/45.md b/45.md
new file mode 100644
index 0000000..cd81c11
--- /dev/null
+++ b/45.md
@@ -0,0 +1,31 @@
1NIP-45
2======
3
4Event Counts
5--------------
6
7`draft` `optional` `author:staab`
8
9Relays may support the `COUNT` verb, which provide a mechanism for obtaining event counts.
10
11## Motivation
12
13Some 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.
14
15## Filters and return values
16
17This NIP defines a verb called `COUNT`, which accepts a subscription id and a filter as specified in [NIP 01](01.md).
18
19Counts are returned using a `COUNT` response in the form `{count: <integer>}`. Relays may use probabilistic counts to reduce compute requirements.
20
21Examples:
22
23```
24# Followers count
25["COUNT", "", {kinds: [3], '#p': [<pubkey>]}]
26["COUNT", "", {count: 238}]
27
28# Count posts and reactions
29["COUNT", "", {kinds: [1, 7], authors: [<pubkey>]}]
30["COUNT", "", {count: 5}]
31```