-
Notifications
You must be signed in to change notification settings - Fork 1
Add offset and limit to ContractsKey and V2ContractsKey
#305
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds pagination support (offset and limit) to the ContractsKey and V2ContractsKey paths across the storage, explorer, API server, client, and OpenAPI spec to address performance and payload size issues when querying contracts by public key.
Changes:
- Extend
ContractsKeyandV2ContractsKeyin the store, explorer, and API layers to acceptoffsetandlimitparameters, and update associated SQL queries to support ordering and pagination. - Update HTTP handlers and the Go API client to parse/query
offsetandlimitfor/pubkey/{key}/contractsand/v2/pubkey/{key}/contracts, with server-side defaults and max-limit enforcement. - Extend tests to call the new paginated signatures and update the OpenAPI specification to document the new query parameters using existing
OffsetParamandLimitParamcomponents.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
persist/sqlite/v2contracts_test.go |
Adjusts TestV2FileContractsKey to call V2ContractsKey with explicit offset and limit, ensuring tests compile with the new signature and still validate DB-level behavior. |
persist/sqlite/v2contracts.go |
Adds offset and limit parameters to V2ContractsKey and applies ORDER BY rev.confirmation_height ASC LIMIT ? OFFSET ? in the SQL query for paginated v2 contracts-by-key retrieval. |
persist/sqlite/contracts_test.go |
Updates TestFileContractsKey to call ContractsKey with explicit offset and limit while preserving its existing behavioral assertions. |
persist/sqlite/contracts.go |
Extends ContractsKey to accept offset and limit, adding explicit ordering by confirmation height and SQL-level pagination for v1 contracts-by-key. |
openapi.yml |
Documents offset and limit as optional query parameters for /v2/pubkey/{key}/contracts and /pubkey/{key}/contracts using the shared OffsetParam and LimitParam components. |
explorer/explorer.go |
Updates the Store interface and Explorer methods so ContractsKey/V2ContractsKey now require offset and limit, propagating pagination into the explorer abstraction. |
api/server.go |
Adds pagination handling (default and max limit, offset parsing) to the pubkey contracts handlers and wires offset/limit through to Explorer.ContractsKey and Explorer.V2ContractsKey. |
api/client.go |
Changes Client.ContractsKey and Client.V2ContractsKey to accept offset and limit and include them in the request URLs to the corresponding endpoints. |
api/api_test.go |
Updates the ContractsKey API test to use the new client signature, verifying the endpoint still returns the expected contract for the renter key. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c876c46 to
3ea435a
Compare
Close #304