input-output-hk / jormungandr

privacy voting blockchain node
https://input-output-hk.github.io/jormungandr/
Apache License 2.0
364 stars 132 forks source link

Endpoint to query blocks by height #768

Open vsubhuman opened 5 years ago

vsubhuman commented 5 years ago

Is your feature request related to a problem/context ? Please describe if applicable. No technical way to query a specific block by knowing the chain height of the block.

Describe the solution you'd like It would be awesome to have a new API endpoint that would take the height as a number and return the raw block or 404.

Maybe something like /api/v0/height/{height}.

If {height} <= 0 - response 400 if {height} > tip_height - response 404

Additional context This endpoint would allow traversing the chain without a help of a second endpoint to query block hashes, we could just start with 1 and query next height until receiving 404, with checking the parent-child relationship preserving on our side, and if we see that the block at the next height refers to some different part - we can just drop N latest blocks and restart with earlier height value.

vsubhuman commented 5 years ago

@CodeSandwich

CodeSandwich commented 5 years ago

@vincenthz This feature will require fetching blocks from store by height. Right now we can fetch only by hash. Is it by design or can I add this feature?

NicolasDP commented 5 years ago

This links to input-output-hk/jormungandr#694

CodeSandwich commented 5 years ago

@NicolasDP Does it only link or should this issue be superseded by GraphQL in explorer mode?

canximan commented 4 years ago

@NicolasDP I have worked with many blockchain platforms to integrate them into a cryptocurrency wallet and ADA testnet is truly a nightmare!