[RPC] Transaction details in getblock #8704
pull achow101 wants to merge 2 commits into bitcoin:master from achow101:getblock-extraverbose changing 3 files +39 −16-
achow101 commented at 2:08 am on September 12, 2016: memberAdds an optional parameter extraVerbose to getblock to have transaction details displayed in a getblock call.
-
fanquake added the label RPC/REST/ZMQ on Sep 12, 2016
-
dcousens commented at 3:10 am on September 12, 2016: contributor
concept NACK, is two RPC requests really so bad?
edit: weak concept NACK
-
achow101 commented at 3:25 am on September 12, 2016: member@dcousens yes, two RPC calls is really bad, especially when you want the details of all the transactions in a block. Then you end up running getrawtransaction thousands of times. Also, AFAICT, this doesn’t require the txindex in order to get the transactions, unlike getrawtransaction.
-
dcousens commented at 3:50 am on September 12, 2016: contributor
@dcousens yes, two RPC calls is really bad
Why? If you’re following best practices (RPC is over localhost only) in terms of access, the latency should be irrelevant.
In a batched RPC call, the overhead is literally just 1RTT more. Not N (aka, thousands), 1.
AFAICT, this doesn’t require the txindex in order to get the transactions, unlike getrawtransaction.
Perhaps
getrawtransaction
should have an optionalblock
parameter?edit: In fact, adding that option would be significantly more useful than this RTT optimisation IMHO.
-
achow101 commented at 4:05 am on September 12, 2016: member
In a batched RPC call, the overhead is literally just 1RTT more. Not N (aka, thousands), 1.
How?
edit: In fact, adding that option would be significantly more useful than this RTT optimisation IMHO.
Well the functionality to this was already in the code. The BlockToJson method took a parameter for txDetails which was by default false. This just lets you set that to true.
-
dcousens commented at 4:11 am on September 12, 2016: contributor
http://www.jsonrpc.org/specification#batch
What language are you using? Your RPC library should be able to handle this quite easily.
-
achow101 commented at 4:27 am on September 12, 2016: memberHuh. Didn’t know that. I’ve been using bash with either curl or bitcoin-cli and python.
-
laanwj commented at 3:33 pm on September 13, 2016: member
Saving roundtrip time is not a valid reason to add a RPC API (see discussion in #8457).
Also, AFAICT, this doesn’t require the txindex in order to get the transactions, unlike getrawtransaction.
This is the only important fact here: you cannot get this information any other way. getrawtransaction won’t get you transactions in blocks, at least without tx index.
The only way to get this information right now is to getblock raw then parse the block locally.
So concept ACK because of that.
-
laanwj commented at 9:24 am on September 14, 2016: member
would it maybe be better to add functionality via getrawtransaction w/ a block id? (perhaps in addition to this)
Well yes a “gather transaction [X,…] from prespecified block Y” RPC call could be useful in some rare cases. But on the other hand it’ll still have to read the entire block from disk and deserialize it. It’s terribly inefficient already. So if it decoded the entire block why not report details for the entire block as done here?
-
in src/rpc/blockchain.cpp: in 0115d18b82 outdated
688@@ -689,11 +689,12 @@ UniValue getblockheader(const UniValue& params, bool fHelp) 689 690 UniValue getblock(const UniValue& params, bool fHelp) 691 { 692- if (fHelp || params.size() < 1 || params.size() > 2) 693+ if (fHelp || params.size() < 1 || params.size() > 3) 694 throw runtime_error( 695- "getblock \"hash\" ( verbose )\n" 696+ "getblock \"hash\" ( verbose ) ( extraVerbose )\n"
luke-jr commented at 8:42 am on October 18, 2016:Double boolean here seems ugly. Maybe allow verbose to be boolean or a number 0-2 (with 2 being extraVerbose)?
laanwj commented at 9:15 am on October 18, 2016:I do agree that for a new interface, a scale for verbosity would have made more sense instead of a boolean. Maybe that’s a better choice I’m just not sure. Changing the meaning of existing arguments is always annoying and means extra testing for backwards compatibility.laanwj commented at 11:33 am on October 26, 2016: memberI’m starting to realize that @luke-jr’s idea to accept 0-2 isn’t such a bad idea after all. Just rename the argument ‘verbosityLevel’. It is easier to use and understand from a user perspective than two booleans (we regularly get confused there in the tests ourselves). Also it’d remove having to deal with the redundant and nonsensical combo
verbose=false extraVerbose=true
.It should still accept
false
andtrue
too. For consistency we should do the same ingetrawtransaction
. This method currently accepts averbose
argument that can be0
or1
but notfalse
ortrue
. The mappingfalse:0,true:1
should be added there (not in this pull though).Also: needs rebase.
achow101 commented at 3:03 pm on October 26, 2016: memberHow should it document in the help message that the old behavior is still accepted?achow101 force-pushed on Oct 26, 2016achow101 commented at 3:29 pm on October 26, 2016: memberRebased and made verbose an int from 0-2in src/rpc/blockchain.cpp: in ad8fc81cde outdated
701+ "The previous behavior of verbose being a boolean is still maintained. False will have the behavior of 0 and True will have the behavior of 1.\n" 702 "\nArguments:\n" 703 "1. \"hash\" (string, required) The block hash\n" 704- "2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n" 705- "\nResult (for verbose = true):\n" 706+ "2. verbose (boolean, optional, default=1) 0 for hex encoded data, 1 for a json object, and 2 for json object with transaction data\n"
luke-jr commented at 5:33 am on November 24, 2016:Should be renamed to verbosity.achow101 force-pushed on Nov 24, 2016luke-jr referenced this in commit 645b21cff4 on Dec 21, 2016achow101 commented at 0:50 am on January 10, 2017: membermerge please?luke-jr approvedluke-jr commented at 4:00 pm on February 3, 2017: memberutACKluke-jr commented at 4:00 pm on February 3, 2017: member(Needs rebase)achow101 force-pushed on Feb 3, 2017achow101 commented at 4:26 pm on February 3, 2017: memberrebasedluke-jr approvedpstratem commented at 0:06 am on February 15, 2017: contributorIs this compatible with callers of getblock which send true instead of 0/1 ?in src/rpc/blockchain.cpp: in 9ada7f04c8 outdated
735+ " \"weight\" : n (numeric) The block weight (BIP 141)\n" 736+ " \"height\" : n, (numeric) The block height or index\n" 737+ " \"version\" : n, (numeric) The block version\n" 738+ " \"versionHex\" : \"00000000\", (string) The block version formatted in hexadecimal\n" 739+ " \"merkleroot\" : \"xxxx\", (string) The merkle root\n" 740+ " \"tx\" : [ (array of Objects) The transactions\n"
jnewbery commented at 11:04 pm on February 15, 2017:I’d suggest not including this in the help output, and just having something like:
0 " \"tx\" : [ (array of Objects) The transactions. Format is the same as for getrawtransaction call\n" 1 " ,...\n" 2 " ],\n"
If the output format of
TxToJSON()
ever changes, I’m sure that changing this help text will be forgotten!sipa commented at 3:29 pm on April 9, 2017: memberNeeds rebase.RPC: Allow multiple names for parameters c99ab3ca4bachow101 force-pushed on Apr 10, 2017luke-jr referenced this in commit ae106ec2b8 on Apr 21, 2017kallewoof commented at 1:09 am on May 12, 2017: memberutACK b779f3093d7b68ee09305a5294c48825dce8ae1fUse a verbosity instead of two verbose parameters
Verbose is changed to an int. This can have values from 0-2 for each level of verbosity. Verbosity level 2 has transaction details displayed in the results.
in src/rpc/blockchain.cpp:722 in b779f3093d outdated
718@@ -716,8 +719,29 @@ UniValue getblock(const JSONRPCRequest& request) 719 " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" 720 " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" 721 "}\n" 722- "\nResult (for verbose=false):\n" 723- "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" 724+ "\nResult (for verbosity = 2):\n"
paveljanik commented at 6:39 am on May 12, 2017:What about mentioning only the differences to verbosity=1 instead?
achow101 commented at 3:47 pm on May 12, 2017:something like this?
0{ 1..., Same as for verbosity=1 2"tx" : [ (array of Objects) The transactions in the format of the getrawtransaction RPC. 3 , ... 4], 5... Same as for verbosity=1 6}
paveljanik commented at 3:50 pm on May 12, 2017:Yup, or maybe even better:
0Additional output (for verbosity=1):...
achow101 force-pushed on May 12, 2017achow101 commented at 3:59 pm on May 12, 2017: member@paveljanik I made the change.laanwj commented at 3:20 pm on May 15, 2017: memberTested ACK e3c9f2dlaanwj merged this on May 15, 2017laanwj closed this on May 15, 2017
laanwj referenced this in commit 96c850c209 on May 15, 2017achow101 deleted the branch on May 17, 2017luke-jr referenced this in commit ad10ed859a on Jun 15, 2017wirwolf referenced this in commit 229a2d8e43 on Sep 28, 2017zkbot referenced this in commit e57c0b0d1c on May 1, 2018zkbot referenced this in commit 53fa6f1315 on May 1, 2018achow101 restored the branch on Aug 17, 2018achow101 deleted the branch on Aug 17, 2018thephez referenced this in commit b652fe17d3 on Dec 17, 2018thephez referenced this in commit 28514b62d7 on Dec 26, 2018laanwj referenced this in commit 3b59fa2ce8 on Jan 19, 2019PastaPastaPasta referenced this in commit 4e6eba8208 on Jun 26, 2021PastaPastaPasta referenced this in commit 7269286cd4 on Jun 26, 2021PastaPastaPasta referenced this in commit 4dcae64501 on Jun 27, 2021PastaPastaPasta referenced this in commit 29645d5832 on Jun 28, 2021DrahtBot locked this on Sep 8, 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-11-17 12:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me