upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViktor Vsk <me@viktorvsk.com>2023-08-20 04:04:55 +0200
committerGitHub <noreply@github.com>2023-08-19 23:04:55 -0300
commitc5a8b75abd9ad5c0b2a680f71ae2c91beda37d5a (patch)
tree5bce1ba9418b7f1f224e781152223cc385f98031
parent37c4375e297166df8350c8a7d119d33c0757228b (diff)
Consistency and small refinements for NIP-01 (#731)
-rw-r--r--01.md22
1 files changed, 11 insertions, 11 deletions
diff --git a/01.md b/01.md
index 6369743..d6ccfbe 100644
--- a/01.md
+++ b/01.md
@@ -25,7 +25,7 @@ The only object type that exists is the `event`, which has the following format
25 ... 25 ...
26 ], 26 ],
27 "content": <arbitrary string>, 27 "content": <arbitrary string>,
28 "sig": <64-bytes hex of the signature of the sha256 hash of the serialized event data, which is the same as the "id" field> 28 "sig": <64-bytes lowercase hex of the signature of the sha256 hash of the serialized event data, which is the same as the "id" field>
29} 29}
30``` 30```
31 31
@@ -34,7 +34,7 @@ To obtain the `event.id`, we `sha256` the serialized event. The serialization is
34```json 34```json
35[ 35[
36 0, 36 0,
37 <pubkey, as a (lowercase) hex string>, 37 <pubkey, as a lowercase hex string>,
38 <created_at, as a number>, 38 <created_at, as a number>,
39 <kind, as a number>, 39 <kind, as a number>,
40 <tags, as an array of arrays of non-null strings>, 40 <tags, as an array of arrays of non-null strings>,
@@ -64,11 +64,11 @@ The first element of the tag array is referred to as the tag _name_ or _key_ and
64 64
65This NIP defines 3 standard tags that can be used accross all event kinds with the same meaning. They are as follows: 65This NIP defines 3 standard tags that can be used accross all event kinds with the same meaning. They are as follows:
66 66
67- The `e` tag, used to refer to an event: `["e", <32-bytes hex of the id of another event>, <recommended relay URL, optional>]` 67- The `e` tag, used to refer to an event: `["e", <32-bytes lowercase hex of the id of another event>, <recommended relay URL, optional>]`
68- The `p` tag, used to refer to another user: `["p", <32-bytes hex of a pubkey>, <recommended relay URL, optional>]` 68- The `p` tag, used to refer to another user: `["p", <32-bytes lowercase hex of a pubkey>, <recommended relay URL, optional>]`
69- The `a` tag, used to refer to a parameterized replaceable event: `["a", <kind integer>:<32-bytes hex of a pubkey>:<d tag value>, <recommended relay URL, optional>]` 69- The `a` tag, used to refer to a parameterized replaceable event: `["a", <kind integer>:<32-bytes lowercase hex of a pubkey>:<d tag value>, <recommended relay URL, optional>]`
70 70
71As a convention, all single-letter key tags are expected to be indexed by relays, such that it is possible, for example, to query or subscribe to events that reference the event `"5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"` by using the `{"#e": "5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"}` filter. 71As a convention, all single-letter (only english alphabet letters: a-z, A-Z) key tags are expected to be indexed by relays, such that it is possible, for example, to query or subscribe to events that reference the event `"5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"` by using the `{"#e": "5c83da77af1dec6d7289834998ad7aafbd9e2191396d75ec3cc27f5a77226f36"}` filter.
72 72
73### Kinds 73### Kinds
74 74
@@ -80,7 +80,7 @@ Kinds specify how clients should interpret the meaning of each event and the oth
80And also a convention for kind ranges that allow for easier experimentation and flexibility of relay implementation: 80And also a convention for kind ranges that allow for easier experimentation and flexibility of relay implementation:
81 81
82- for kind `n` such that `1000 <= n < 10000`, events are **regular**, which means they're all expected to be stored by relays. 82- for kind `n` such that `1000 <= n < 10000`, events are **regular**, which means they're all expected to be stored by relays.
83- for kind `n` such that `10000 <= n < 20000 || k == 0 || k == 3`, events are **replaceable**, which means that, for each combination of `pubkey` and `kind`, only the latest event is expected to be stored by relays, older versions are expected to be discarded. 83- for kind `n` such that `10000 <= n < 20000 || k == 0 || k == 3`, events are **replaceable**, which means that, for each combination of `pubkey` and `kind`, only the latest event is expected to (SHOULD) be stored by relays, older versions are expected to be discarded.
84- for kind `n` such that `20000 <= n < 30000`, events are **ephemeral**, which means they are not expected to be stored by relays. 84- for kind `n` such that `20000 <= n < 30000`, events are **ephemeral**, which means they are not expected to be stored by relays.
85- for kind `n` such that `30000 <= n < 40000`, events are **parameterized replaceable**, which means that, for each combination of `pubkey`, `kind` and the `d` tag, only the latest event is expected to be stored by relays, older versions are expected to be discarded. 85- for kind `n` such that `30000 <= n < 40000`, events are **parameterized replaceable**, which means that, for each combination of `pubkey`, `kind` and the `d` tag, only the latest event is expected to be stored by relays, older versions are expected to be discarded.
86 86
@@ -90,7 +90,7 @@ These are just conventions and relay implementations may differ.
90 90
91## Communication between clients and relays 91## Communication between clients and relays
92 92
93Relays expose a websocket endpoint to which clients can connect. Clients should open a single websocket connection to each relay and use it for all their subscriptions. 93Relays expose a websocket endpoint to which clients can connect. Clients SHOULD open a single websocket connection to each relay and use it for all their subscriptions. Relays MAY limit number of connections from specific IP/client/etc.
94 94
95### Meaning of WebSocket status codes 95### Meaning of WebSocket status codes
96 96
@@ -113,14 +113,14 @@ Clients can send 3 types of messages, which must be JSON arrays, according to th
113 "ids": <a list of event ids>, 113 "ids": <a list of event ids>,
114 "authors": <a list of lowercase pubkeys, the pubkey of an event must be one of these>, 114 "authors": <a list of lowercase pubkeys, the pubkey of an event must be one of these>,
115 "kinds": <a list of a kind numbers>, 115 "kinds": <a list of a kind numbers>,
116 "#<single-letter>": <a list of event ids that are referenced in the tag specified by the single letter>, 116 "#<single-letter (a-zA-Z)>": <a list of tag values, for #e — a list of event ids, for #p — a list of event pubkeys etc>,
117 "since": <an integer unix timestamp in seconds, events must be newer than this to pass>, 117 "since": <an integer unix timestamp in seconds, events must be newer than this to pass>,
118 "until": <an integer unix timestamp in seconds, events must be older than this to pass>, 118 "until": <an integer unix timestamp in seconds, events must be older than this to pass>,
119 "limit": <maximum number of events to be returned in the initial query> 119 "limit": <maximum number of events relays SHOULD return in the initial query>
120} 120}
121``` 121```
122 122
123Upon receiving a `REQ` message, the relay SHOULD query its internal database and return events that match the filter, then store that filter and send again all future events it receives to that same websocket until the websocket is closed. The `CLOSE` event is received with the same `<subscription_id>` or a new `REQ` is sent using the same `<subscription_id>`, in which case it should overwrite the previous subscription. 123Upon receiving a `REQ` message, the relay SHOULD query its internal database and return events that match the filter, then store that filter and send again all future events it receives to that same websocket until the websocket is closed. The `CLOSE` event is received with the same `<subscription_id>` or a new `REQ` is sent using the same `<subscription_id>`, in which case relay MUST overwrite the previous subscription.
124 124
125Filter attributes containing lists (`ids`, `authors`, `kinds` and tag filters like `#e`) are JSON arrays with one or more values. At least one of the arrays' values must match the relevant field in an event for the condition to be considered a match. For scalar event attributes such as `authors` and `kind`, the attribute from the event must be contained in the filter list. In the case of tag attributes such as `#e`, for which an event may have multiple values, the event and filter condition values must have at least one item in common. 125Filter attributes containing lists (`ids`, `authors`, `kinds` and tag filters like `#e`) are JSON arrays with one or more values. At least one of the arrays' values must match the relevant field in an event for the condition to be considered a match. For scalar event attributes such as `authors` and `kind`, the attribute from the event must be contained in the filter list. In the case of tag attributes such as `#e`, for which an event may have multiple values, the event and filter condition values must have at least one item in common.
126 126