aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-07-06 08:06:35 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-07-06 08:06:40 -0400
commitb52e25cc1be3771cad26c6c3cdbc0b81f96597ec (patch)
treeb3b48c15f35a355afc74d863a211a89711f97114 /src/rpc/util.cpp
parentf4301e9107924c101d7738de4123b8a5c888bad5 (diff)
parent40506bf93f955adfbc446c4d5fee4fa8bcfd7d9a (diff)
downloadbitcoin-b52e25cc1be3771cad26c6c3cdbc0b81f96597ec.tar.xz
Merge #19328: Add gettxoutsetinfo hash_type option
40506bf93f955adfbc446c4d5fee4fa8bcfd7d9a test: Test gettxouttsetinfo hash_type option (Fabian Jahr) f17a4d1c4ddce6935a353004898fb4e8618a213e rpc: Add hash_type NONE to gettxoutsetinfo (Fabian Jahr) a712cf6f6801157667fcf36d1c498b6fff6d328a rpc: gettxoutsetinfo can specify hash_type (only legacy option for now) (Fabian Jahr) 605884ef21318fc3f326dbdf4901cb353ba63fab refactor: Extract GetBogoSize function (Fabian Jahr) Pull request description: This is another intermediate part of the Coinstats Index (tracked in #18000). Sjors suggested [here](https://github.com/bitcoin/bitcoin/pull/18000#issuecomment-641423019) that the part of the changes in #19145 that don't rely on the new `hash_type` muhash, i.e. that are for `hash_type=none`, could be merged separately from everything involving muhash. So these changes are extracted from #19145 here and can be merged without any other requirements. Building the index with no UTXO set hash is still valuable because `gettxoutsetinfo` can still be used to audit the `total_amount` for example. By itself this PR is not a huge improvement, `hash_type=none` is speeding up `gettxoutsetinfo` by about 10%, but it enables the implementation of an index on top of it in a follow-up and that means large parts of the index code of Coinstats Index can be merged while reviews for the hashing algorithm might take longer. ACKs for top commit: MarcoFalke: ACK 40506bf93f955adfbc446c4d5fee4fa8bcfd7d9a 🖨 Sjors: tACK 40506bf93f955adfbc446c4d5fee4fa8bcfd7d9a Tree-SHA512: 3964c2b8eed427511b1aa9b2ef285dff27dc4d1537d72c3911e435b6e6b40912232da4acb3a09bd19a0372ddffa44103388d8a650169d95a4a727b970d210add
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r--src/rpc/util.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index 54ea352a72..ca73c699c9 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -113,6 +113,23 @@ std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey)
return ParseHexV(find_value(o, strKey), strKey);
}
+CoinStatsHashType ParseHashType(const UniValue& param, const CoinStatsHashType default_type)
+{
+ if (param.isNull()) {
+ return default_type;
+ } else {
+ std::string hash_type_input = param.get_str();
+
+ if (hash_type_input == "hash_serialized_2") {
+ return CoinStatsHashType::HASH_SERIALIZED;
+ } else if (hash_type_input == "none") {
+ return CoinStatsHashType::NONE;
+ } else {
+ throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%d is not a valid hash_type", hash_type_input));
+ }
+ }
+}
+
std::string HelpExampleCli(const std::string& methodname, const std::string& args)
{
return "> bitcoin-cli " + methodname + " " + args + "\n";