Merge bitcoin/bitcoin#25485: rpc: Use enum instead of string for filtertype_name

baf4efe02f363b70011b04cadd2d7aace18d48e9 rpc: use enum instead of string for filter type (w0xlt)

Pull request description:

  This PR changes the `getblockfilter` RPC to use `BlockFilterType` enum instead of a repeated string for `filtertype_name`.

ACKs for top commit:
  furszy:
    ACK baf4efe0
  brunoerg:
    ACK baf4efe02f363b70011b04cadd2d7aace18d48e9

Tree-SHA512: 31c79c0a5f0b17fd69b399bb026f523003b656733d6b7d5ffe665921a8cc0f1e0334d2e465145cd89fbd85e196059cf56f4f11563bbc92948b0606080ca76524
This commit is contained in:
MacroFake 2022-06-28 08:17:29 +02:00
commit ee3ba5a76f
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

View File

@ -2177,7 +2177,7 @@ static RPCHelpMan getblockfilter()
"\nRetrieve a BIP 157 content filter for a particular block.\n", "\nRetrieve a BIP 157 content filter for a particular block.\n",
{ {
{"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hash of the block"}, {"blockhash", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hash of the block"},
{"filtertype", RPCArg::Type::STR, RPCArg::Default{"basic"}, "The type name of the filter"}, {"filtertype", RPCArg::Type::STR, RPCArg::Default{BlockFilterTypeName(BlockFilterType::BASIC)}, "The type name of the filter"},
}, },
RPCResult{ RPCResult{
RPCResult::Type::OBJ, "", "", RPCResult::Type::OBJ, "", "",
@ -2192,7 +2192,7 @@ static RPCHelpMan getblockfilter()
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{ {
uint256 block_hash = ParseHashV(request.params[0], "blockhash"); uint256 block_hash = ParseHashV(request.params[0], "blockhash");
std::string filtertype_name = "basic"; std::string filtertype_name = BlockFilterTypeName(BlockFilterType::BASIC);
if (!request.params[1].isNull()) { if (!request.params[1].isNull()) {
filtertype_name = request.params[1].get_str(); filtertype_name = request.params[1].get_str();
} }