Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering returned events chronologically #119

Open
xeruf opened this issue Sep 7, 2024 · 2 comments
Open

Ordering returned events chronologically #119

xeruf opened this issue Sep 7, 2024 · 2 comments

Comments

@xeruf
Copy link

xeruf commented Sep 7, 2024

Currently, filter requests seem to be responded to in reverse chronological order - the other way around than in rnostr, which I used previously. Chronological order makes it easier to process reply chains, especially since in my use-case I request potentially thousands of events from a relay. How about a flag to reverse the ordering?

Btw, ordering is entirely unspecified in the official protocol, right? No defaults, no filter options for it.

@hoytech
Copy link
Owner

hoytech commented Sep 7, 2024

I haven't looked into rnostr, but I believe most relays work the same as strfry and return in reverse chronological. Usually this is what you want to build a "twitter-like" experience, although as you say, adds some challenges when you want to reconstruct an entire thread.

The NIP-01 spec only seems to mandate the order when limit is present, in which case it is assumed reverse chron:

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. Newer events should appear first, and in the case of ties the event with the lowest id (first in lexical order) should be first.

strfry always uses newest-first, even without limit. I tried to find a discussion in the NIP repo about this, since I'm sure it's been discussed before, but it's impossible to find anything in there. If you want to help get this clarified in the spec, please open a NIP.

@kcdev001
Copy link

strfry always uses newest-first, even without `limit`

This could lead to some unexpected errors in my product. Is there a way to reverse the query results?

In the application I'm developing, I hope to receive and process messages in chronological order, meaning that messages sent earlier are received first.
Currently, the result is the opposite. I am not setting a limit, only a since, because I need to process all messages.
As: wss://relay.damus.io

In this project https://github.com/scsibug/nostr-rs-relay, if no limit is set, messages are returned in ascending order by time, which meets expectations.
As: backup.keychat.io

Is there a relevant query that can achieve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants