diff options
Diffstat (limited to '01.md')
| -rw-r--r-- | 01.md | 12 |
1 files changed, 9 insertions, 3 deletions
| @@ -141,19 +141,25 @@ Relays can send 4 types of messages, which must also be JSON arrays, according t | |||
| 141 | * `["EVENT", <subscription_id>, <event JSON as defined above>]`, used to send events requested by clients. | 141 | * `["EVENT", <subscription_id>, <event JSON as defined above>]`, used to send events requested by clients. |
| 142 | * `["OK", <event_id>, <true|false>, <message>]`, used to indicate acceptance or denial of an `EVENT` message. | 142 | * `["OK", <event_id>, <true|false>, <message>]`, used to indicate acceptance or denial of an `EVENT` message. |
| 143 | * `["EOSE", <subscription_id>]`, used to indicate the _end of stored events_ and the beginning of events newly received in real-time. | 143 | * `["EOSE", <subscription_id>]`, used to indicate the _end of stored events_ and the beginning of events newly received in real-time. |
| 144 | * `["CLOSED", <subscription_id>, <message>]`, used to indicate that a subscription was ended on the server side. | ||
| 144 | * `["NOTICE", <message>]`, used to send human-readable error messages or other things to clients. | 145 | * `["NOTICE", <message>]`, used to send human-readable error messages or other things to clients. |
| 145 | 146 | ||
| 146 | This NIP defines no rules for how `NOTICE` messages should be sent or treated. | 147 | This NIP defines no rules for how `NOTICE` messages should be sent or treated. |
| 147 | 148 | ||
| 148 | - `EVENT` messages MUST be sent only with a subscription ID related to a subscription previously initiated by the client (using the `REQ` message above). | 149 | - `EVENT` messages MUST be sent only with a subscription ID related to a subscription previously initiated by the client (using the `REQ` message above). |
| 149 | - `OK` messages MUST be sent in response to `EVENT` messages received from clients, they must have the 3rd parameter set to `true` when an event has been accepted by the relay, `false` otherwise. The 4th parameter MUST always be present, but MAY be an empty string when the 3rd is `true`, otherwise it MUST be a string formed by a machine-readable single-word prefix followed by a `:` and then a human-readable message. The standardized machine-readable prefixes are: `duplicate`, `pow`, `blocked`, `rate-limited`, `invalid`, and `error` for when none of that fits. Some examples: | 150 | - `OK` messages MUST be sent in response to `EVENT` messages received from clients, they must have the 3rd parameter set to `true` when an event has been accepted by the relay, `false` otherwise. The 4th parameter MUST always be present, but MAY be an empty string when the 3rd is `true`, otherwise it MUST be a string formed by a machine-readable single-word prefix followed by a `:` and then a human-readable message. Some examples: |
| 150 | |||
| 151 | * `["OK", "b1a649ebe8...", true, ""]` | 151 | * `["OK", "b1a649ebe8...", true, ""]` |
| 152 | * `["OK", "b1a649ebe8...", true, "pow: difficulty 25>=24"]` | 152 | * `["OK", "b1a649ebe8...", true, "pow: difficulty 25>=24"]` |
| 153 | * `["OK", "b1a649ebe8...", true, "duplicate: already have this event"]` | 153 | * `["OK", "b1a649ebe8...", true, "duplicate: already have this event"]` |
| 154 | * `["OK", "b1a649ebe8...", false, "blocked: you are banned from posting here"]` | 154 | * `["OK", "b1a649ebe8...", false, "blocked: you are banned from posting here"]` |
| 155 | * `["OK", "b1a649ebe8...", false, "blocked: please register your pubkey at https://my-expensive-relay.example.com"]` | 155 | * `["OK", "b1a649ebe8...", false, "blocked: please register your pubkey at https://my-expensive-relay.example.com"]` |
| 156 | * `["OK", "b1a649ebe8...", false, "rate-limited: slow down there chief"]` | 156 | * `["OK", "b1a649ebe8...", false, "rate-limited: slow down there chief"]` |
| 157 | * `["OK", "b1a649ebe8...", false, "invalid: event creation date is too far off from the current time. Is your system clock in sync?"]` | 157 | * `["OK", "b1a649ebe8...", false, "invalid: event creation date is too far off from the current time"]` |
| 158 | * `["OK", "b1a649ebe8...", false, "pow: difficulty 26 is less than 30"]` | 158 | * `["OK", "b1a649ebe8...", false, "pow: difficulty 26 is less than 30"]` |
| 159 | * `["OK", "b1a649ebe8...", false, "error: could not connect to the database"]` | 159 | * `["OK", "b1a649ebe8...", false, "error: could not connect to the database"]` |
| 160 | - `CLOSED` messages MUST be sent in response to a `REQ` when the relay refuses to fulfill it. It can also be sent when a relay decides to kill a subscription on its side before a client has disconnected or sent a `CLOSE`. This message uses the same pattern of `OK` messages with the machine-readable prefix and human-readable message. Some examples: | ||
| 161 | * `["CLOSED", "sub1", "duplicate: sub1 already opened"]` | ||
| 162 | * `["CLOSED", "sub1", "unsupported: filter contains unknown elements"]` | ||
| 163 | * `["CLOSED", "sub1", "error: could not connect to the database"]` | ||
| 164 | * `["CLOSED", "sub1", "error: shutting down idle subscription"]` | ||
| 165 | - The standardized machine-readable prefixes for `OK` and `CLOSED` are: `duplicate`, `pow`, `blocked`, `rate-limited`, `invalid`, and `error` for when none of that fits. | ||