Skip to content
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

Add Route to Fetch Blocks by Tenure Height #2144

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

bowtiedbot
Copy link

Add a route that opens an endpoint on the API that allows users to fetch the blocks by tenure height:

/extended/v2/tenure-height/{height}/blocks

This endpoint returns the same data as /extended/v2/burn-blocks/{height_or_hash}/blocks does, but by the tenure height instead of the burn height/hash.

@CLAassistant
Copy link

CLAassistant commented Oct 27, 2024

CLA assistant check
All committers have signed the CLA.

@smcclellan smcclellan requested a review from zone117x November 1, 2024 15:29
Copy link
Collaborator

@rafaelcr rafaelcr left a comment

Choose a reason for hiding this comment

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

Hi @bowtiedbot thanks for the contribution and apologies for the review delay.

@@ -99,6 +100,7 @@ export const StacksApiRoutes: FastifyPluginAsync<
async fastify => {
await fastify.register(BlockRoutesV2, { prefix: '/blocks' });
await fastify.register(BurnBlockRoutesV2, { prefix: '/burn-blocks' });
await fastify.register(TenureHeightRoutesV2, { prefix: '/tenure-height' });
Copy link
Collaborator

Choose a reason for hiding this comment

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

For v2 endpoints we're trying to keep route names as REST-ful as possible, so we want to group endpoints according to the entity that they return. Adding tenure-height here would not fit the standard.

Could you instead add a tenure_height query param to the /extended/v2/blocks endpoint? That will also allow you to get cursor pagination for free and will work much better with API clients.

Copy link
Author

Choose a reason for hiding this comment

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

Hello @rafaelcr! I am currently trying to modify the query from pg-store-v2, but when parsing a tenure height query, the results list is empty. Can you please take a look over it and let me know what I'm doing wrong? Thank you!

https://github.com/degen-lab/stacks-blockchain-api/blob/test/get-blocks-by-tenure-height/src/datastore/pg-store-v2.ts#L76-L140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🏗 In Progress
Development

Successfully merging this pull request may close these issues.

3 participants