Skip to content

Conversation

@jonasschnelli
Copy link
Contributor

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.

@jgarzik
Copy link
Contributor

jgarzik commented Sep 30, 2018

concept ACK

Copy link
Contributor

@jimmysong jimmysong left a comment

Choose a reason for hiding this comment

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

Thanks @jonasschnelli !

@promag
Copy link
Contributor

promag commented Oct 1, 2018

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?

@jonasschnelli
Copy link
Contributor Author

@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.

@gmaxwell
Copy link
Contributor

gmaxwell commented Oct 1, 2018

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.

@jonasschnelli jonasschnelli changed the title REST: add blockheader call, fetch blockhash by height REST: add blockhash call, fetch blockhash by height Oct 1, 2018
@jonasschnelli
Copy link
Contributor Author

Changed the title (was wrong, thank @gmaxwell)

I'm happy to add a per-height accessing to /rest/block, but this would mean accessing that new per-height-fetching would always return a block (optionally reduced to only contain txids) which would always access the disk.

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).

@ch4ot1c
Copy link
Contributor

ch4ot1c commented Oct 2, 2018

Ack, seems marginally beneficial

jonasschnelli added a commit to jonasschnelli/simple-block-explorer that referenced this pull request Oct 7, 2018
@jonasschnelli jonasschnelli force-pushed the 2018/09/rest_blockhash branch from ae0a5a1 to 8e9cb6b Compare October 17, 2018 19:44
@promag
Copy link
Contributor

promag commented Oct 18, 2018

utACK, but fix first commit message.

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 9, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #11770 ([REST] add a rest endpoint for estimatesmartfee, docs, and test by joemphilips)

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.

@luke-jr
Copy link
Member

luke-jr commented Dec 20, 2018

See also #11765

@jonasschnelli jonasschnelli force-pushed the 2018/09/rest_blockhash branch from 8e9cb6b to 3a93411 Compare January 3, 2019 22:04
@jonasschnelli
Copy link
Contributor Author

Fixed @luke-jr point (invalid JSON respons)
Renamed from blockhash to blockhashbyheight.

Copy link
Member

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

@laanwj
Copy link
Member

laanwj commented Jan 4, 2019

utACK (-nit), I'm surprised this didn't exist yet.

Copy link
Member

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/....

@jonasschnelli jonasschnelli force-pushed the 2018/09/rest_blockhash branch from 3a93411 to d63921b Compare January 4, 2019 18:55
@jonasschnelli
Copy link
Contributor Author

Fixed documentation and the test comment inconsistency (reported by @laanwj)

Copy link
Contributor

@jnewbery jnewbery left a 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 :)

@jonasschnelli jonasschnelli force-pushed the 2018/09/rest_blockhash branch from d63921b to c8937f4 Compare January 19, 2019 06:10
@jonasschnelli
Copy link
Contributor Author

Fixed points reported by @jnewbery (thanks for the review).

@promag
Copy link
Contributor

promag commented Jan 20, 2019

@jonasschnelli commit messages should mention /rest/blockhashbyheight.

@jonasschnelli jonasschnelli force-pushed the 2018/09/rest_blockhash branch from c8937f4 to 42ff30e Compare January 21, 2019 21:55
@jonasschnelli
Copy link
Contributor Author

Fixed the commit message

@jnewbery
Copy link
Contributor

utACK 42ff30e

@promag
Copy link
Contributor

promag commented Jan 22, 2019

utACK 42ff30e.

@jonasschnelli jonasschnelli merged commit 42ff30e into bitcoin:master Jan 23, 2019
jonasschnelli added a commit that referenced this pull request Jan 23, 2019
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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 30, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 28, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants