-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Labels
Milestone
Description
What problem does your feature solve?
There's no efficient way to query the N most recent events matching a filter. The getEvents endpoint only returns events in ascending order, forcing clients who want "latest events" to either:
- Scan the entire retention window and discard all but the last N events
- Guess a
startLedgernear the tip and retry with expanded windows on misses - Implement binary search to find recent events
This is a common need for any tool that requires fetching latest activity.
What would you like to see?
An optional order field in pagination options:
{
"startLedger": 1000,
"pagination": {
"limit": 10,
"order": "desc"
},
"filters": [...]
}| Value | Behavior |
|---|---|
"asc" (default) |
Current behavior - oldest first |
"desc" |
Newest first, starting from endLedger (or latest ledger) |
Implementation cost should be low:
- No database changes - existing composite indexes support reverse scans
- Fully backwards compatible - defaults to
"asc"
What alternatives are there?
- Client-side filtering: Fetch all events in ascending order, keep last N. Inefficient and wasteful.
- Heuristic windowing: Start queries near latest ledger, expand on miss. Unreliable and complex for clients.
- External indexing: Use a separate service like SubQuery or a custom indexer. Adds operational complexity for a simple use case.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
To Do