upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Thibault <jdthibault2@gmail.com>2023-01-06 10:58:30 -0500
committerfiatjaf <fiatjaf@gmail.com>2023-01-07 17:53:24 -0300
commit741ac01b970d318fd61406087dd21371eb1a1e55 (patch)
tree6b96c255284f1185f840632b69eb8ec365ce131a
parent01a3090c6ab872621e01019c58f8cac38c354c25 (diff)
NIP-22: use nip-20; minor updates
-rw-r--r--22.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/22.md b/22.md
index 9ab601d..fb29e6a 100644
--- a/22.md
+++ b/22.md
@@ -8,7 +8,7 @@ Event `created_at` Limits
8 8
9Relays may define both upper and lower limits within which they will consider an event's `created_at` to be acceptable. Both the upper and lower limits MUST be unix timestamps in seconds as defined in [NIP-01](01.md). 9Relays may define both upper and lower limits within which they will consider an event's `created_at` to be acceptable. Both the upper and lower limits MUST be unix timestamps in seconds as defined in [NIP-01](01.md).
10 10
11If a relay supports this NIP, the relay SHOULD send the client a `NOTICE` message saying the event was not stored for the `created_at` timestamp not being within the permitted limits. 11If a relay supports this NIP, the relay SHOULD send the client a [NIP-20](20.md) command result saying the event was not stored for the `created_at` timestamp not being within the permitted limits.
12 12
13Client Behavior 13Client Behavior
14--------------- 14---------------
@@ -22,24 +22,24 @@ This NIP formalizes restrictions on event timestamps as accepted by a relay and
22 22
23The event `created_at` field is just a unix timestamp and can be set to a time in the past or future. Relays accept and share events dated to 20 years ago or 50,000 years in the future. This NIP aims to define a way for relays that do not want to store events with *any* timestamp to set their own restrictions. 23The event `created_at` field is just a unix timestamp and can be set to a time in the past or future. Relays accept and share events dated to 20 years ago or 50,000 years in the future. This NIP aims to define a way for relays that do not want to store events with *any* timestamp to set their own restrictions.
24 24
25[Replaceable events](16.md#replaceable-events) can behave rather unexpected if the user wrote them - or tried to write them - with a wrong system clock. Persisting an update with a backdated system now would result in the update not getting persisted without a `NOTICE` and if they did the last update with a forward dated system, they will again fail to do another update with the now correct time. 25[Replaceable events](16.md#replaceable-events) can behave rather unexpected if the user wrote them - or tried to write them - with a wrong system clock. Persisting an update with a backdated system now would result in the update not getting persisted without a notification and if they did the last update with a forward dated system, they will again fail to do another update with the now correct time.
26 26
27A wide adoption of this nip could create a better user experience as it would decrease the amount of events that appear wildly out of order or even from impossible dates in the distant past or future. 27A wide adoption of this NIP could create a better user experience as it would decrease the amount of events that appear wildly out of order or even from impossible dates in the distant past or future.
28 28
29Keep in mind that there is a use case where a user migrates their old posts onto a new relay. If a relay rejects events that were not recently created, it cannot serve this use case. 29Keep in mind that there is a use case where a user migrates their old posts onto a new relay. If a relay rejects events that were not recently created, it cannot serve this use case.
30 30
31 31
32Python Example 32Python (pseudocode) Example
33-------------- 33---------------------------
34 34
35```python 35```python
36import time 36import time
37 37
38TIME = int(time.now) 38TIME = int(time.time())
39LOWER_LIMIT = TIME - (60 * 60 * 24) # Define lower limit as 1 day into the past 39LOWER_LIMIT = TIME - (60 * 60 * 24) # Define lower limit as 1 day into the past
40UPPER_LIMIT = TIME + (60 * 15) # Define upper limit as 15 minutes into the future 40UPPER_LIMIT = TIME + (60 * 15) # Define upper limit as 15 minutes into the future
41 41
42if event.created_at not in range(LOWER_LIMIT, UPPER_LIMIT): 42if event.created_at not in range(LOWER_LIMIT, UPPER_LIMIT):
43 # NOTE: This is one example of a notice message. Relays can change this to notify clients however they like. 43 ws.send('["OK", event.id, False, "invalid: the event created_at field is out of the acceptable range (-24h, +15min) for this relay"]')
44 ws.send('["NOTICE", "The event created_at field is out of the acceptable range (-24h, +15min) for this relay and was not stored."]')
45``` 44```
45Note: These are just example limits, the relay operator can choose whatever limits they want.