Skip to content

feat: add pagination and new filters to query orders#313

Merged
pablocampogo merged 2 commits intomainfrom
new-orders-endpoint
Feb 19, 2026
Merged

feat: add pagination and new filters to query orders#313
pablocampogo merged 2 commits intomainfrom
new-orders-endpoint

Conversation

@pablocampogo
Copy link
Contributor

Summary

This PR enhances the /v1/query/orders RPC endpoint with filtering capabilities and pagination support for efficiently querying sell orders at scale.

Changes

New Features

  • Added committee filter parameter to query orders for a specific committee
  • Added sellersSendAddress filter parameter with a secondary index for efficient O(log n) lookups
  • Added pagination support (pageNumber, perPage) with standard Page response format

Storage Layer (fsm/)

  • Added new orderBySellerPrefix key prefix for the seller address secondary index
  • Added OrderBySellerPrefix, OrderBySellerAndChainPrefix, and KeyForOrderBySeller key functions
  • Updated SetOrder() to write to both primary store and secondary index
  • Updated DeleteOrder() to clean up both primary and secondary index entries
  • Added GetOrdersPaginated() with helper methods for all filter combinations
  • Added GetOrdersBySeller() for non-paginated seller address queries

RPC Layer (cmd/rpc/)

  • Added SellOrders type implementing Pageable interface for pagination support
  • Updated ordersRequest to include committee, sellersSendAddress, and PageParams
  • Updated Orders handler to use paginated queries with filter support
  • Added ordersParams helper function

Documentation

  • Updated README with new request parameters and response format
  • Added examples for all filter combinations with pagination

Filter Combinations

Filter Query Strategy
None Iterates all orders (paginated)
committee only Prefix scan on committee (paginated)
sellersSendAddress only Secondary index lookup (paginated)
Both filters Most efficient - composite index lookup (paginated)

@pablocampogo pablocampogo self-assigned this Feb 19, 2026
}

// ordersParams is a helper function to abstract common workflows around a callback requiring a state machine and orders request
func (s *Server) ordersParams(w http.ResponseWriter, r *http.Request, callback func(s *fsm.StateMachine, request *ordersRequest) (any, lib.ErrorI)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is the exact same one as the one above orderParams but with a different struct, there are multiple implementations like this on this file (likely AI generated) but is unmaintainable long term as it is requiring a different function for every different struct, this is a perfect example to use generics or use any/type-casting to minimize this issue, no further actions based on this, just documenting for future refactors

@pablocampogo pablocampogo merged commit e1b7910 into main Feb 19, 2026
2 checks passed
@rem1niscence rem1niscence deleted the new-orders-endpoint branch February 19, 2026 22:19
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.

2 participants

Comments