-
Notifications
You must be signed in to change notification settings - Fork 38.7k
REST: add blockhash call, fetch blockhash by height #14353
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
REST: add blockhash call, fetch blockhash by height #14353
Conversation
|
concept ACK |
1477ecb to
ae0a5a1
Compare
jimmysong
left a comment
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.
Thanks @jonasschnelli !
|
Tested ACK ae0a5a1. What is the use case? Query block hash by height and then query the block? If so could overload /rest/block instead to avoid 2nd round trip? |
|
@promag: the use case is exactly that (find a block by giving a height) (ex: https://bitcointools.jonasschnelli.ch/explorer/height/500000). You could build it into /rest/block, but IMO we should keep it modular. I guess that is also the reason why there is a "getblock" and a "getblockhash" call on RPC. |
|
PR is mistitled, not a "blockheader" call. This PR doesn't really seem to indicate the benefit this provides to the user. Making multiple round trips also has bad performance, if the purpose really is just querying blocks by height this indirection seems like pretextual modularity. |
|
Changed the title (was wrong, thank @gmaxwell) I'm happy to add a per-height accessing to Of course, we could then add it to /rest/headers/ as well so one would fetch a single blockheader (or range of headers) per height. I haven't made a study about use cases but the extra roundtrip made sense to me (costs for http mem only retrieval roundtrips are usually tiny). |
|
Ack, seems marginally beneficial |
ae0a5a1 to
8e9cb6b
Compare
|
utACK, but fix first commit message. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
See also #11765 |
8e9cb6b to
3a93411
Compare
|
Fixed @luke-jr point (invalid JSON respons) |
test/functional/interface_rest.py
Outdated
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.
nit: this is /blockhashbyheight now
|
utACK (-nit), I'm surprised this didn't exist yet. |
doc/REST-interface.md
Outdated
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.
The help for RPC getblockhash is Returns hash of block in best-block-chain at height provided. I think that's slightly better terminology to use here than "main chain" which could be confused with testnet/mainnet/....
3a93411 to
d63921b
Compare
|
Fixed documentation and the test comment inconsistency (reported by @laanwj) |
jnewbery
left a comment
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.
looks good. A few comments, mostly around better test coverage :)
d63921b to
c8937f4
Compare
|
Fixed points reported by @jnewbery (thanks for the review). |
|
@jonasschnelli commit messages should mention /rest/blockhashbyheight. |
c8937f4 to
42ff30e
Compare
|
Fixed the commit message |
|
utACK 42ff30e |
|
utACK 42ff30e. |
42ff30e [Docs] add short documentation for /rest/blockhashbyheight (Jonas Schnelli) 579d418 [QA] add rest tests for /rest/blockhashbyheight/<HEIGHT>.<FORMAT> (Jonas Schnelli) eb9ef04 REST: add "blockhashbyheight" call, fetch blockhash by height (Jonas Schnelli) Pull request description: Completes the REST interface for trivial block exploring by adding a call that allows to fetch the blockhash in the main chain by a given height. Tree-SHA512: 94be9e56718f857279b11cc16dfa8d04f3b5a762e87ae54281b4d87247c71c844895f4944d5a47f09056bf851f4c4761ac4fbdbaaee957265d14de5c1c73e8d2
Summary: [QA] add rest tests for /rest/blockhashbyheight/<HEIGHT>.<FORMAT> [Docs] add short documentation for /rest/blockhashbyheight This is a backport of Core [[bitcoin/bitcoin#14353 | PR14353]] Test Plan: `ninja && ninja check-functional` Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7681
42ff30e [Docs] add short documentation for /rest/blockhashbyheight (Jonas Schnelli) 579d418 [QA] add rest tests for /rest/blockhashbyheight/<HEIGHT>.<FORMAT> (Jonas Schnelli) eb9ef04 REST: add "blockhashbyheight" call, fetch blockhash by height (Jonas Schnelli) Pull request description: Completes the REST interface for trivial block exploring by adding a call that allows to fetch the blockhash in the main chain by a given height. Tree-SHA512: 94be9e56718f857279b11cc16dfa8d04f3b5a762e87ae54281b4d87247c71c844895f4944d5a47f09056bf851f4c4761ac4fbdbaaee957265d14de5c1c73e8d2
Completes the REST interface for trivial block exploring by adding a call that allows to fetch the blockhash in the main chain by a given height.