mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
refactor: enable readability-container-contains clang-tidy rule
Replace the last few instances of `.count() != 0` and `.count() == 0` and `.count()` patterns with the more expressive C++20 `.contains()` method: * `std::set<std::string>` in `getblocktemplate` RPC; * `std::map<std::string, ...>` in `transaction_tests`; * other bare `std::unordered_set` and `std::map` count calls. With no remaining violations, enable the `readability-container-contains` clang-tidy check to prevent future regressions.
This commit is contained in:
@@ -846,12 +846,12 @@ static RPCHelpMan getblocktemplate()
|
||||
const Consensus::Params& consensusParams = chainman.GetParams().GetConsensus();
|
||||
|
||||
// GBT must be called with 'signet' set in the rules for signet chains
|
||||
if (consensusParams.signet_blocks && setClientRules.count("signet") != 1) {
|
||||
if (consensusParams.signet_blocks && !setClientRules.contains("signet")) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "getblocktemplate must be called with the signet rule set (call with {\"rules\": [\"segwit\", \"signet\"]})");
|
||||
}
|
||||
|
||||
// GBT must be called with 'segwit' set in the rules
|
||||
if (setClientRules.count("segwit") != 1) {
|
||||
if (!setClientRules.contains("segwit")) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "getblocktemplate must be called with the segwit rule set (call with {\"rules\": [\"segwit\"]})");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user