From 9ef39553e464d1ecd656f57b615ce1aa72c39176 Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 12 Apr 2023 23:18:22 +0800 Subject: [PATCH] feat: support counting by filters --- 45.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/45.md b/45.md index 28e5e969..87e80002 100644 --- a/45.md +++ b/45.md @@ -14,18 +14,26 @@ Some queries a client may want to execute against connected relays are prohibiti ## 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", , ...] +``` Counts are returned using a `COUNT` response in the form `{count: }`. Relays may use probabilistic counts to reduce compute requirements. +``` +["COUNT", , {"count": }] +``` + Examples: ``` # Followers count -["COUNT", "", {kinds: [3], '#p': []}] -["COUNT", "", {count: 238}] +["COUNT", , {"kinds": [3], "#p": []}] +["COUNT", , {"count": 238}] # Count posts and reactions -["COUNT", "", {kinds: [1, 7], authors: []}] -["COUNT", "", {count: 5}] +["COUNT", , {"kinds": [1, 7], "authors": []}] +["COUNT", , {"count": 5}] ```