[REST] /rest/block response with full tx details #5391

pull jonasschnelli wants to merge 3 commits into bitcoin:master from jonasschnelli:rest-block-with-tx changing 4 files +65 −7
  1. jonasschnelli commented at 7:33 PM on November 28, 2014: contributor
    • rest block request returns full unfolded tx details
  2. jonasschnelli commented at 7:35 PM on November 28, 2014: contributor

    Currently the rpc getblock call is untouched. Maybe it would also make sense to unfold the tx details there (could also be behind a optional boolean parameter).

    Example: http://paste.ubuntu.com/9287277/ (testnet block 00000000009e9cc0e7df2ad4a0fcae52794b50764087e1e01e57c102e3ee01ec)

  3. jonasschnelli commented at 7:39 PM on November 28, 2014: contributor

    Currently some informations in the tx part is doubled (blockhash, blocktime, confirmations, time, etc.). Could also be removed, but currently the output is equal to the /rest/txoutput.

  4. in src/rpcblockchain.cpp:None in 0dd6570f0a outdated
      74 | +            TxToJSON(tx, block.GetHash(), objTx);
      75 | +            txs.push_back(objTx);
      76 | +        }
      77 | +        else
      78 | +        {
      79 | +            BOOST_FOREACH(const CTransaction&tx, block.vtx)
    


    sipa commented at 8:16 PM on November 28, 2014:

    Two nested iterations over all block transactions?

  5. jonasschnelli force-pushed on Nov 28, 2014
  6. jonasschnelli commented at 8:23 PM on November 28, 2014: contributor

    Damit! Clerical mistakes. Thanks for the review!

  7. jonasschnelli commented at 11:04 AM on December 3, 2014: contributor

    Any tests on this? This would make sense to have in 0.10 because it legitimates the json output format.

  8. laanwj added the label RPC on Dec 5, 2014
  9. laanwj added this to the milestone 0.10.0 on Dec 5, 2014
  10. laanwj commented at 9:51 AM on December 5, 2014: member

    No argument from me to not include this in 0.10. But can you update the RPC test to test this?

  11. jonasschnelli commented at 10:29 AM on December 5, 2014: contributor

    Good point. I will write some tests.

    I think it's okay if this is not in 0.10. If people start using REST this PR would make loading all transitions of a block much easier and it uses less resources.

  12. jonasschnelli force-pushed on Dec 6, 2014
  13. jonasschnelli commented at 9:31 AM on December 6, 2014: contributor

    Updated:

    1. Added some rpc tests for the block request with tx-details
    2. Added a url schema for block with and without transaction details (/rest/block/notxdetails/<HASH>)

    I found out that sometimes it's useful to get a block (JSON) without transactions details, thats why i kept the original implementation of returning a block with no transaction subdata. Otherwise large blocks can result in a huge JSON response.

  14. laanwj commented at 9:43 AM on December 6, 2014: member

    Thanks!

    Otherwise large blocks can result in a huge JSON response.

    But isn't that the point of getblock, to get all block data? JSON is just a terribly inefficient way of representing it. Although I suppose it would be very possible to come up with a more efficient JSON format, the RPC format may have grown redundancies over time.

    Anyhow, no opposition against adding a notxdetails mode.

  15. jonasschnelli force-pushed on Dec 6, 2014
  16. jonasschnelli commented at 10:00 AM on December 6, 2014: contributor

    Just added some documentation for the new behavior.

    I wouldn't say JSON is a bad format for a block representation. Some people nowadays tend to use flexible transport formats like JSON to make a more flexible implementation in cost of cpu/mem resources. I think thats feasible. A REST API with bin only format would be not user-friendly IMO. I think supporting bin and JSON is a sustainable way for both kind of possible REST-Users (memory-low-ressource-fanatics and overhead-json-lovers).

  17. laanwj commented at 10:45 AM on December 6, 2014: member

    Speaking about overhead: I think TxToJSON needs a flag to exclude some fields when used in the 'whole-block' representation, as it is repeated info:

    • blockhash
    • confirmations
    • time/blocktime (are the same)

    Just a matter of skipping this code block: https://github.com/bitcoin/bitcoin/blob/master/src/rpcrawtransaction.cpp#L92

  18. jonasschnelli commented at 6:09 PM on December 6, 2014: contributor

    Right. Thanks. Just pushed a change that will fix this overhead.

  19. laanwj commented at 2:59 PM on December 9, 2014: member

    Tested ACK apart from above nit.

  20. jonasschnelli force-pushed on Dec 9, 2014
  21. jonasschnelli force-pushed on Dec 9, 2014
  22. [REST] /rest/block response with full tx details
    - rest block request returns full unfolded tx details
    - /rest/block/notxdetails/<HASH> returns block where transactions are only represented by its hash
    73351c3686
  23. [REST] added /rest/block/notxdetails/<hash> into REST-interface.md documentation cae548685d
  24. [REST] JSON output: remove block infos from tx details if it is nested in block 932ef50f77
  25. jonasschnelli force-pushed on Dec 9, 2014
  26. jonasschnelli commented at 3:06 PM on December 9, 2014: contributor

    Fixed the nit. Rebased.

  27. laanwj merged this on Dec 11, 2014
  28. laanwj closed this on Dec 11, 2014

  29. laanwj referenced this in commit 5e521d3e4e on Dec 11, 2014
  30. MarcoFalke locked this on Sep 8, 2021

Milestone
0.10.0


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: 2026-04-13 15:15 UTC

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