diff options
| author | fiatjaf_ <fiatjaf@gmail.com> | 2023-08-09 07:26:51 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-09 07:26:51 -0300 |
| commit | 5026747008c0a84c14079c39807296eebd409c36 (patch) | |
| tree | adbc9bf9038d776d74ad7fdd62f7b49132f5a1db /01.md | |
| parent | 9fa9045d19b93f4cbac231bff39558108a6e82ae (diff) | |
| parent | ce7e6b2100918648ec4341c5fe517d076e8d225c (diff) | |
Merge branch 'master' into vending-machine
Diffstat (limited to '01.md')
| -rw-r--r-- | 01.md | 8 |
1 files changed, 5 insertions, 3 deletions
| @@ -55,7 +55,7 @@ Clients can send 3 types of messages, which must be JSON arrays, according to th | |||
| 55 | * `["REQ", <subscription_id>, <filters JSON>...]`, used to request events and subscribe to new updates. | 55 | * `["REQ", <subscription_id>, <filters JSON>...]`, used to request events and subscribe to new updates. |
| 56 | * `["CLOSE", <subscription_id>]`, used to stop previous subscriptions. | 56 | * `["CLOSE", <subscription_id>]`, used to stop previous subscriptions. |
| 57 | 57 | ||
| 58 | `<subscription_id>` is an arbitrary, non-empty string of max length 64 chars, that should be used to represent a subscription. | 58 | `<subscription_id>` is an arbitrary, non-empty string of max length 64 chars, that should be used to represent a subscription. Relays should manage `<subscription_id>`s independently for each WebSocket connection; even if `<subscription_id>`s are the same string, they should be treated as different subscriptions for different connections. |
| 59 | 59 | ||
| 60 | `<filters>` is a JSON object that determines what events will be sent in that subscription, it can have the following attributes: | 60 | `<filters>` is a JSON object that determines what events will be sent in that subscription, it can have the following attributes: |
| 61 | 61 | ||
| @@ -78,11 +78,13 @@ Filter attributes containing lists (such as `ids`, `kinds`, or `#e`) are JSON ar | |||
| 78 | 78 | ||
| 79 | The `ids` and `authors` lists contain lowercase hexadecimal strings, which may either be an exact 64-character match, or a prefix of the event value. A prefix match is when the filter string is an exact string prefix of the event value. The use of prefixes allows for more compact filters where a large number of values are queried, and can provide some privacy for clients that may not want to disclose the exact authors or events they are searching for. | 79 | The `ids` and `authors` lists contain lowercase hexadecimal strings, which may either be an exact 64-character match, or a prefix of the event value. A prefix match is when the filter string is an exact string prefix of the event value. The use of prefixes allows for more compact filters where a large number of values are queried, and can provide some privacy for clients that may not want to disclose the exact authors or events they are searching for. |
| 80 | 80 | ||
| 81 | The `since` and `until` properties can be used to specify the time range of events returned in the subscription. If a filter includes the `since` property, events with `created_at` greater than or equal to `since` are considered to match the filter. The `until` property is similar except that `created_at` must be less than or equal to `until`. In short, an event matches a filter if `since <= created_at <= until` holds. | ||
| 82 | |||
| 81 | All conditions of a filter that are specified must match for an event for it to pass the filter, i.e., multiple conditions are interpreted as `&&` conditions. | 83 | All conditions of a filter that are specified must match for an event for it to pass the filter, i.e., multiple conditions are interpreted as `&&` conditions. |
| 82 | 84 | ||
| 83 | A `REQ` message may contain multiple filters. In this case, events that match any of the filters are to be returned, i.e., multiple filters are to be interpreted as `||` conditions. | 85 | A `REQ` message may contain multiple filters. In this case, events that match any of the filters are to be returned, i.e., multiple filters are to be interpreted as `||` conditions. |
| 84 | 86 | ||
| 85 | The `limit` property of a filter is only valid for the initial query and can be ignored afterward. When `limit: n` is present it is assumed that the events returned in the initial query will be the latest `n` events. It is safe to return less events than `limit` specifies, but it is expected that relays do not return (much) more events than requested so clients don't get unnecessarily overwhelmed by data. | 87 | The `limit` property of a filter is only valid for the initial query and can be ignored afterward. When `limit: n` is present it is assumed that the events returned in the initial query will be the last `n` events ordered by the `created_at`. It is safe to return less events than `limit` specifies, but it is expected that relays do not return (much) more events than requested so clients don't get unnecessarily overwhelmed by data. |
| 86 | 88 | ||
| 87 | ### From relay to client: sending events and notices | 89 | ### From relay to client: sending events and notices |
| 88 | 90 | ||
| @@ -107,7 +109,7 @@ A relay may choose to treat different message kinds differently, and it may or m | |||
| 107 | ## Other Notes: | 109 | ## Other Notes: |
| 108 | 110 | ||
| 109 | - Clients should not open more than one websocket to each relay. One channel can support an unlimited number of subscriptions, so clients should do that. | 111 | - Clients should not open more than one websocket to each relay. One channel can support an unlimited number of subscriptions, so clients should do that. |
| 110 | - The `tags` array can store a tag identifier as the first element of each subarray, plus arbitrary information afterward (always as strings). This NIP defines `"p"` — meaning "pubkey", which points to a pubkey of someone that is referred to in the event —, and `"e"` — meaning "event", which points to the id of an event this event is quoting, replying to or referring to somehow. See [NIP-10](10.md) for a detailed description of "e" and "p" tags. | 112 | - The `tags` array can store a case-sensitive tag name as the first element of each subarray, plus arbitrary information afterward (always as strings). This NIP defines `"p"` — meaning "pubkey", which points to a pubkey of someone that is referred to in the event —, and `"e"` — meaning "event", which points to the id of an event this event is quoting, replying to or referring to somehow. See [NIP-10](10.md) for a detailed description of "e" and "p" tags. |
| 111 | - The `<recommended relay URL>` item present on the `"e"` and `"p"` tags is an optional (could be set to `""`) URL of a relay the client could attempt to connect to fetch the tagged event or other events from a tagged profile. It MAY be ignored, but it exists to increase censorship resistance and make the spread of relay addresses more seamless across clients. | 113 | - The `<recommended relay URL>` item present on the `"e"` and `"p"` tags is an optional (could be set to `""`) URL of a relay the client could attempt to connect to fetch the tagged event or other events from a tagged profile. It MAY be ignored, but it exists to increase censorship resistance and make the spread of relay addresses more seamless across clients. |
| 112 | - Clients should use the created_at field to judge the age of a metadata event and completely replace older metadata events with newer metadata events regardless of the order in which they arrive. Clients should not merge any filled fields within older metadata events into empty fields of newer metadata events. | 114 | - Clients should use the created_at field to judge the age of a metadata event and completely replace older metadata events with newer metadata events regardless of the order in which they arrive. Clients should not merge any filled fields within older metadata events into empty fields of newer metadata events. |
| 113 | - When a websocket is closed by the relay with a status code 4000 that means the client shouldn't try to connect again. | 115 | - When a websocket is closed by the relay with a status code 4000 that means the client shouldn't try to connect again. |