- rest block request returns full unfolded tx details
[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-
jonasschnelli commented at 7:33 PM on November 28, 2014: contributor
-
jonasschnelli commented at 7:35 PM on November 28, 2014: contributor
Currently the rpc
getblockcall 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)
-
jonasschnelli commented at 7:39 PM on November 28, 2014: contributor
Currently some informations in the
txpart is doubled (blockhash,blocktime,confirmations,time, etc.). Could also be removed, but currently the output is equal to the/rest/txoutput. -
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?
jonasschnelli force-pushed on Nov 28, 2014jonasschnelli commented at 8:23 PM on November 28, 2014: contributorDamit! Clerical mistakes. Thanks for the review!
jonasschnelli commented at 11:04 AM on December 3, 2014: contributorAny tests on this? This would make sense to have in 0.10 because it legitimates the json output format.
laanwj added the label RPC on Dec 5, 2014laanwj added this to the milestone 0.10.0 on Dec 5, 2014laanwj commented at 9:51 AM on December 5, 2014: memberNo argument from me to not include this in 0.10. But can you update the RPC test to test this?
jonasschnelli commented at 10:29 AM on December 5, 2014: contributorGood 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.
jonasschnelli force-pushed on Dec 6, 2014jonasschnelli commented at 9:31 AM on December 6, 2014: contributorUpdated:
- Added some rpc tests for the block request with tx-details
- 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.
laanwj commented at 9:43 AM on December 6, 2014: memberThanks!
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.
jonasschnelli force-pushed on Dec 6, 2014jonasschnelli commented at 10:00 AM on December 6, 2014: contributorJust 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
binonly format would be not user-friendly IMO. I think supportingbinandJSONis a sustainable way for both kind of possible REST-Users (memory-low-ressource-fanatics and overhead-json-lovers).laanwj commented at 10:45 AM on December 6, 2014: memberSpeaking 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
jonasschnelli commented at 6:09 PM on December 6, 2014: contributorRight. Thanks. Just pushed a change that will fix this overhead.
laanwj commented at 2:59 PM on December 9, 2014: memberTested ACK apart from above nit.
jonasschnelli force-pushed on Dec 9, 2014jonasschnelli force-pushed on Dec 9, 201473351c3686[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
[REST] added /rest/block/notxdetails/<hash> into REST-interface.md documentation cae548685d[REST] JSON output: remove block infos from tx details if it is nested in block 932ef50f77jonasschnelli force-pushed on Dec 9, 2014jonasschnelli commented at 3:06 PM on December 9, 2014: contributorFixed the nit. Rebased.
laanwj merged this on Dec 11, 2014laanwj closed this on Dec 11, 2014laanwj referenced this in commit 5e521d3e4e on Dec 11, 2014MarcoFalke locked this on Sep 8, 2021
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
More mirrored repositories can be found on mirror.b10c.me