This pull fixes the example curl command for getblockstats which doesn't work as is because it's missing a comma between the params and has single quotes around the second parameter.
It also adds an additional example of getting block stats by hash by using a known workaround (#15412) to get bitcoin-cli to treat the hash parameter as JSON instead of a string since there is ongoing deliberation about how or whether to fix the root issue (#15448).
rpc: doc: Fix and extend getblockstats examples #17831
pull asoltys wants to merge 1 commits into bitcoin:master from asoltys:getblockstats-examples changing 1 files +4 −2-
asoltys commented at 7:41 AM on December 30, 2019: contributor
- asoltys force-pushed on Dec 30, 2019
- DrahtBot added the label RPC/REST/ZMQ on Dec 30, 2019
-
in src/rpc/blockchain.cpp:1757 in 1078183496 outdated
1753 | @@ -1754,8 +1754,10 @@ static UniValue getblockstats(const JSONRPCRequest& request) 1754 | "}\n" 1755 | }, 1756 | RPCExamples{ 1757 | - HelpExampleCli("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'") 1758 | - + HelpExampleRpc("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'") 1759 | + HelpExampleCli("getblockstats", "'\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"' '[\"minfeerate\",\"avgfeerate\"]'") +
andrewtoth commented at 10:31 PM on December 30, 2019:Using raw string literals will make this more readable.
HelpExampleCli("getblockstats", R"('"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"', '["minfeerate","avgfeerate"]')") +
asoltys commented at 12:34 AM on December 31, 2019:Nice, rebased with your suggestion
asoltys force-pushed on Dec 31, 2019asoltys force-pushed on Dec 31, 2019asoltys force-pushed on Dec 31, 2019in src/rpc/blockchain.cpp:1758 in 687818c06e outdated
1753 | @@ -1754,8 +1754,10 @@ static UniValue getblockstats(const JSONRPCRequest& request) 1754 | "}\n" 1755 | }, 1756 | RPCExamples{ 1757 | - HelpExampleCli("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'") 1758 | - + HelpExampleRpc("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'") 1759 | + HelpExampleCli("getblockstats", R"('"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"' '["minfeerate","avgfeerate"]')") + 1760 | + HelpExampleCli("getblockstats", R"("1000 '["minfeerate","avgfeerate"]'")") +
theStack commented at 5:21 PM on March 20, 2020:This doesn't equal to the original HelpExampleCli string anymore, as there are two extra quotation marks at the beginning and end:
Branch Source-code representation Visible result master "1000 '[\"minfeerate\",\"avgfeerate\"]'"1000 '["minfeerate","avgfeerate"]'PR17831 R"("1000 '["minfeerate","avgfeerate"]'")""1000 '["minfeerate","avgfeerate"]'"$ bitcoin-cli getblockstats "1000 '["minfeerate","avgfeerate"]'" error: Error parsing JSON:1000 '[minfeerate,avgfeerate]'
theStack commented at 5:24 PM on March 20, 2020:HelpExampleCli("getblockstats", R"(1000 '["minfeerate","avgfeerate"]')") +in src/rpc/blockchain.cpp:1760 in 687818c06e outdated
1753 | @@ -1754,8 +1754,10 @@ static UniValue getblockstats(const JSONRPCRequest& request) 1754 | "}\n" 1755 | }, 1756 | RPCExamples{ 1757 | - HelpExampleCli("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'") 1758 | - + HelpExampleRpc("getblockstats", "1000 '[\"minfeerate\",\"avgfeerate\"]'") 1759 | + HelpExampleCli("getblockstats", R"('"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"' '["minfeerate","avgfeerate"]')") + 1760 | + HelpExampleCli("getblockstats", R"("1000 '["minfeerate","avgfeerate"]'")") + 1761 | + HelpExampleRpc("getblockstats", R"("00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09", ["minfeerate","avgfeerate"])") + 1762 | + HelpExampleRpc("getblockstats", R"("1000, ["minfeerate","avgfeerate"]")")
theStack commented at 5:27 PM on March 20, 2020:Same problem as above here, there are two extra quotation marks that break the example:
$ curl --user __cookie__ --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockstats", "params": ["1000, ["minfeerate","avgfeerate"]"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/ Enter host password for user '__cookie__': {"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}
theStack commented at 5:28 PM on March 20, 2020:HelpExampleRpc("getblockstats", R"(1000, ["minfeerate","avgfeerate"])")
asoltys commented at 6:03 AM on April 17, 2020:Thanks for catching this. I fixed and rebased on latest master and added you as co-author on the commit.
theStack changes_requestedtheStack commented at 5:41 PM on March 20, 2020: memberThere is a slight problem with superfluous quotation marks (probably happened with the usage of raw strings), see my code review comments plus change suggestions. Apart from that, LGTM: tested that the new example of getting block stats by hash works fine (both for CLI and RPC) and that the fix approach for the curl example of getting block stats by height is right. :+1:
asoltys force-pushed on Apr 17, 2020asoltys commented at 4:41 PM on April 17, 2020: contributorI think this is ready for merging now. Requesting review @jonasschnelli @MarcoFalke
asoltys force-pushed on Apr 17, 2020709998467erpc: doc: Fix and extend getblockstats examples
This fixes the example curl command for `getblockstats` which is missing a comma between the params and has single quotes around the second parameter. Besides fixing the existing example, this commit adds an additional example of getting block stats by hash by using a known workaround with bitcoin-cli to get it to treat the hash parameter as a JSON string by wrapping it in both single and double quotes. Co-Authored-By: Andrew Toth <andrewstoth@gmail.com> Co-Authored-By: Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
asoltys force-pushed on Apr 18, 2020theStack approvedtheStack commented at 7:20 PM on April 18, 2020: memberMarcoFalke merged this on Apr 20, 2020MarcoFalke closed this on Apr 20, 2020Fabcien referenced this in commit 5f734a013f on Jan 19, 2021PastaPastaPasta referenced this in commit 7f631dbb14 on Dec 22, 2021PastaPastaPasta referenced this in commit ce24ca5794 on Dec 22, 2021PastaPastaPasta referenced this in commit c65f526ac1 on Dec 22, 2021PastaPastaPasta referenced this in commit affb7a472f on Dec 28, 2021DrahtBot locked this on Feb 15, 2022
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:14 UTC
More mirrored repositories can be found on mirror.b10c.me