Skip to content

Add offset and limit to ContractsKey and V2ContractsKey#305

Merged
ChrisSchinnerl merged 4 commits intomasterfrom
christopher/offset-limit-contracts-key
Feb 4, 2026
Merged

Add offset and limit to ContractsKey and V2ContractsKey#305
ChrisSchinnerl merged 4 commits intomasterfrom
christopher/offset-limit-contracts-key

Conversation

@chris124567
Copy link
Member

Close #304

Copilot AI review requested due to automatic review settings February 3, 2026 00:55
@github-project-automation github-project-automation bot moved this to In Progress in Sia Feb 3, 2026
Copy link

Copilot AI left a 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 ContractsKey and V2ContractsKey in the store, explorer, and API layers to accept offset and limit parameters, and update associated SQL queries to support ordering and pagination.
  • Update HTTP handlers and the Go API client to parse/query offset and limit for /pubkey/{key}/contracts and /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 OffsetParam and LimitParam components.

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.

@chris124567 chris124567 force-pushed the christopher/offset-limit-contracts-key branch from c876c46 to 3ea435a Compare February 3, 2026 01:08
@chris124567 chris124567 requested review from ChrisSchinnerl, n8mgr and peterjan and removed request for Copilot February 3, 2026 01:09
peterjan
peterjan previously approved these changes Feb 3, 2026
@ChrisSchinnerl ChrisSchinnerl merged commit 08fadec into master Feb 4, 2026
10 checks passed
@ChrisSchinnerl ChrisSchinnerl deleted the christopher/offset-limit-contracts-key branch February 4, 2026 09:39
@github-project-automation github-project-automation bot moved this from In Progress to Done in Sia Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Support limit/offset for ContractsKey and V2ContractsKey

3 participants