Skip to content

Conversation

@tomerweller
Copy link
Contributor

Summary

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

Usage

{
  "startLedger": 1000,
  "pagination": {
    "limit": 10,
    "order": "desc"
  },
  "filters": [...]
}

Notes

🤖 Generated with Claude Code

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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant