From 537ad9f455181a121feb520d4e61584abd51cda8 Mon Sep 17 00:00:00 2001 From: arthurfranca Date: Tue, 27 Jun 2023 11:15:05 -0300 Subject: [PATCH] Rename algo to NIP-34asc --- 34.md | 13 ++++++------- 34a.md => 34asc.md | 21 ++++++++------------- 2 files changed, 14 insertions(+), 20 deletions(-) rename 34a.md => 34asc.md (77%) diff --git a/34.md b/34.md index 0bae4176..16ad34be 100644 --- a/34.md +++ b/34.md @@ -46,8 +46,7 @@ Into this: ## How Clients Make Custom Requests for a Specific User -The algorithms are global, meaning the "score" represented by the new event field isn't considering -specific user preferences. +The algorithms are generic, meaning the "score" represented by the new event field does not differ for different users. However, smart `clients` may keep track of pubkeys from whom the user is consuming content, also hashtags, for instance, and use such pubkeys/hashtags as a way to tailor the query to that specific user. For example: @@ -57,18 +56,18 @@ However, smart `clients` may keep track of pubkeys from whom the user is consumi Each algorithm section describes **how** and **when** to compute the corresponding database field for each event. -For example, [NIP-34a](34a.md) extension teaches `relays` the math used to update the `nip34a` event field. +For example, [NIP-34asc](34asc.md) extension teaches `relays` the math used to update the `nip34asc` event field. The NIP extension MUST have atleast one example in any programming language, preferably with inline comments. All algorithms' field values MUST be **unique strings** for each event. This is needed to support the most rudimentary databases that `relays` may be using such as file DBs. -The event id may be appended to the string to make it unique, similar to NIP-34a solution. +The event id may be appended to the string to make it unique, similar to NIP-34asc solution. Bugfixes and small updates to embrace new event kinds may be submitted at any time by the algorithm author(s). ## Available Algorithms -| Extension | Name | Description | Modification Date | -| ------------- | ------------ | -------------------------------------------------- | ----------------- | -| [34a](34a.md) | Oldest First | Events with older `created_at` are retrieved first | 12 / jun / 2023 | +| Extension | Name | Description | Modification Date | +| ----------------- | ----------| -------------------------------------------------- | ----------------- | +| [34asc](34asc.md) | Ascending | Events with older `created_at` are retrieved first | 12 / jun / 2023 | diff --git a/34a.md b/34asc.md similarity index 77% rename from 34a.md rename to 34asc.md index 99d1424d..045c06a4 100644 --- a/34a.md +++ b/34asc.md @@ -1,8 +1,8 @@ -NIP-34a -======= +NIP-34asc +========= -Oldest First ------------- +Ascending +--------- `draft` `optional` `author:arthurfranca` @@ -10,9 +10,9 @@ Events with older `created_at` are retrieved first. ## Implementation -`Relay` computes `nip34a` field once upon receiving the event. +`Relay` computes `nip34asc` field once upon receiving the event. -The lower the `created_at`, the higher `nip34a` will be. +The lower the `created_at`, the higher `nip34asc` will be. ### Javascript @@ -24,7 +24,7 @@ const maxDateNowSeconds = 8640000000000 // 8.64e15 ms / 1000 const maxTs = maxDateNowSeconds * 2 const maxSecondsLength = maxTs.toString().length -function getNip34a (createdAt, id = '') { +function getNip34asc (createdAt, id = '') { // The id length must always be the same to not affect sorting if (id.length !== 64) { throw new Error('Wrong id length') } let seconds = Math.trunc(createdAt) // Make sure it is int instead of float @@ -42,10 +42,5 @@ function getNip34a (createdAt, id = '') { return `${paddedTsSeconds}${id}` } -event.nip34a = getNip34a(event.created_at, event.id) +event.nip34asc = getNip34asc(event.created_at, event.id) ``` - -## Notes - -This implementation should be updated if we find out a popular programming -language doesn't support 17280000000000 int.