Add order parameter to getEvents PaginationOptions#5888
Draft
tomerweller wants to merge 2 commits intostellar:mainfrom
Draft
Add order parameter to getEvents PaginationOptions#5888tomerweller wants to merge 2 commits intostellar:mainfrom
order parameter to getEvents PaginationOptions#5888tomerweller wants to merge 2 commits intostellar:mainfrom
Conversation
This adds an optional `order` field to PaginationOptions for the getEvents endpoint, allowing clients to retrieve events in descending order (newest first). Changes: - Add EventOrder type with "asc" and "desc" constants - Add Order field to PaginationOptions struct - Add IsValid() method for order validation - Update GetEventsRequest.Valid() to validate order parameter - Add tests for order validation This enables efficient querying of the N most recent events without scanning the entire retention window. Fully backwards compatible - defaults to ascending order when not specified. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tomerweller
added a commit
to tomerweller/stellar-rpc
that referenced
this pull request
Dec 20, 2025
This adds an optional `order` field to the getEvents pagination options, allowing clients to retrieve events in descending order (newest first). Changes: - Update DB layer to accept order parameter for query direction - Update handler to use protocol.EventOrder types - Add tests for descending order, limit with descending, and invalid order This feature enables efficient querying of the N most recent events without scanning the entire retention window. The implementation is fully backwards compatible - order defaults to "asc" when not specified. Depends on: stellar/go-stellar-sdk#5888 Closes stellar#575 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5 tasks
Document how the interpretation of StartLedger and EndLedger changes based on the pagination order parameter: - For ascending order: StartLedger is lower bound, EndLedger is upper bound - For descending order: StartLedger is upper bound, EndLedger is lower bound This ensures consistent semantics where StartLedger always represents where scanning begins and EndLedger where it ends. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tomerweller
added a commit
to tomerweller/stellar-rpc
that referenced
this pull request
Dec 22, 2025
This adds an optional `order` field to the getEvents pagination options, allowing clients to retrieve events in descending order (newest first). Changes: - Update DB layer to accept order parameter for query direction - Update handler to use protocol.EventOrder types - Add tests for descending order, limit with descending, and invalid order This feature enables efficient querying of the N most recent events without scanning the entire retention window. The implementation is fully backwards compatible - order defaults to "asc" when not specified. Depends on: stellar/go-stellar-sdk#5888 Closes stellar#575 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
orderfield toPaginationOptionsfor thegetEventsendpoint, allowing clients to retrieve events in descending order (newest first).Changes
EventOrdertype with"asc"and"desc"constantsOrderfield toPaginationOptionsstructIsValid()method for order validationGetEventsRequest.Valid()to validate order parameterUsage
{ "startLedger": 1000, "pagination": { "limit": 10, "order": "desc" }, "filters": [...] }Notes
orderparameter togetEventsfor descending order support stellar-rpc#576orderparameter togetEventsfor descending order support stellar-rpc#575🤖 Generated with Claude Code