RPC: Add feature to getblock by using the index #16317

pull emilengler wants to merge 1 commits into bitcoin:master from emilengler:getblock-improvement changing 1 files +13 −2
  1. emilengler commented at 2:30 am on June 30, 2019: contributor

    Hello, this PR adds a feature to getblock which allows to get the blockdata directly without the need for using getblockhash first.

    First it checks if you have provided an input smaller than 64 characters. After that it checks if the input is a valid number or if it contains letters. If it is a valid number it will request the blockhash for this index.

    The feature to use the hash directly works of course as well.

    If the user provides an input which is smaller than 64 characters and is not a valid number it will return an error.

    The changes were tested by myself and they work.

    The reason for this improvement is that it is too exaggerated for me to first get the hash of an index and then get the block data with two separate commands.

  2. Add feature to getblock by using the index a2f6b2ff93
  3. fanquake added the label RPC/REST/ZMQ on Jun 30, 2019
  4. DrahtBot commented at 2:52 am on June 30, 2019: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #16240 (JSONRPCRequest-aware RPCHelpMan by kallewoof)

    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.

  5. promag commented at 8:19 am on June 30, 2019: member
    This was attempted before and rejected. Last attempted #14858.
  6. laanwj commented at 12:57 pm on July 4, 2019: member

    Besides the conceptual discussion, I think this particular implementation has a few issues:

    • Interpreting a string as a number breaks API consistency; sure, from bitcoin-cli you won’t be able to see the difference, but from other languages using RPC it’s unexpected to have to handle a number differently from other places
    • Overloading based on how the value looks just feels wrong to me

    If we really want this (I’m doubtful about this, but it seems to come up often) then my suggestion would be to define a new RPC call getblockbyheight instead of the usually brittle ways to re-define arguments.

  7. emilengler commented at 1:15 pm on July 4, 2019: contributor
    Good point, haven’t had this in mind when I was doing it. To your second point, I think it would become problematic only if the block height becomes 64-digits long. But I’m also convinced now that a separate RPC call is probably a better solution.
  8. emilengler closed this on Jul 4, 2019

  9. promag commented at 1:19 pm on July 4, 2019: member
    What it the problem of 2 calls?
  10. emilengler commented at 1:25 pm on July 4, 2019: contributor
    Actually I don’t see a problem with two calls as it is the best solution. But I would prefer to do this in a new pull request rather than by this.
  11. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 13:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me