upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Casarin <jb55@jb55.com>2022-08-15 13:09:53 -0700
committerGitHub <noreply@github.com>2022-08-15 13:09:53 -0700
commitf6346b6e2265013acdcbc6dacd4a00b69394da0c (patch)
tree87b59b9aba0b58f089d302a161b617ba22459c07
parent7fe572ec5a7321726c9469f70a93bb278be8d774 (diff)
parent903cc0992eedd752a688ce11c77d8a7bea57ae82 (diff)
Merge pull request #22 from jeffthibault/nip22-unacceptable-event-time
NIP-22: event created_at limits
-rw-r--r--22.md42
-rw-r--r--README.md1
2 files changed, 43 insertions, 0 deletions
diff --git a/22.md b/22.md
new file mode 100644
index 0000000..e4cea51
--- /dev/null
+++ b/22.md
@@ -0,0 +1,42 @@
1NIP-22
2======
3
4Event `created_at` Limits
5---------------------------
6
7`draft` `optional` `author:jeffthibault` `author:Giszmo`
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).
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.
12
13Client Behavior
14---------------
15
16Clients SHOULD use the [NIP-11](11.md) `supported_nips` field to learn if a relay uses event `created_at` time limits as defined by this NIP.
17
18Motivation
19----------
20
21This NIP formalizes restrictions on event timestamps as accepted by a relay and allows clients to be aware of relays that have these restrictions.
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.
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.
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.
28
29Python Example
30--------------
31
32```python
33import time
34
35TIME = int(time.now)
36LOWER_LIMIT = TIME - (60 * 60 * 24) # Define lower limit as 1 day into the past
37UPPER_LIMIT = TIME + (60 * 15) # Define upper limit as 15 minutes into the future
38
39if event.created_at not in range(LOWER_LIMIT, UPPER_LIMIT):
40 # NOTE: This is one example of a notice message. Relays can change this to notify clients however they like.
41 ws.send('["NOTICE", "The event created_at field is out of the acceptable range (-24h, +15min) for this relay and was not stored."]')
42```
diff --git a/README.md b/README.md
index acf8689..e1858a9 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,7 @@ NIPs stand for **Nostr Implementation Possibilities**. They exist to document wh
18- [NIP-14: Subject tag in text events.](14.md) 18- [NIP-14: Subject tag in text events.](14.md)
19- [NIP-15: End of Stored Events Notice](15.md) 19- [NIP-15: End of Stored Events Notice](15.md)
20- [NIP-16: Event Treatment](16.md) 20- [NIP-16: Event Treatment](16.md)
21- [NIP-22: Event created_at Limits](22.md)
21- [NIP-25: Reactions](25.md) 22- [NIP-25: Reactions](25.md)
22 23
23## Event Kinds 24## Event Kinds