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:
Lőrinc
2025-12-18 22:37:30 +01:00
parent fd9f1accbd
commit 1e94e562f7
5 changed files with 11 additions and 10 deletions

View File

@@ -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\"]})");
}