refactor: add more consts everywhere as required by cppcheck 2.13.0

This commit is contained in:
Konstantin Akimov 2024-02-23 20:43:23 +07:00
parent 61a6c407fe
commit add99ea862
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
6 changed files with 16 additions and 16 deletions

View File

@ -220,7 +220,7 @@ bool CActiveMasternodeManager::GetLocalAddress(CService& addrRet)
return true; return true;
} }
bool CActiveMasternodeManager::IsValidNetAddr(CService addrIn) bool CActiveMasternodeManager::IsValidNetAddr(const CService& addrIn)
{ {
// TODO: regtest is fine with any addresses for now, // TODO: regtest is fine with any addresses for now,
// should probably be a bit smarter if one day we start to implement tests for this // should probably be a bit smarter if one day we start to implement tests for this

View File

@ -61,7 +61,7 @@ public:
std::string GetStateString() const; std::string GetStateString() const;
std::string GetStatus() const; std::string GetStatus() const;
static bool IsValidNetAddr(CService addrIn); static bool IsValidNetAddr(const CService& addrIn);
private: private:
bool GetLocalAddress(CService& addrRet); bool GetLocalAddress(CService& addrRet);

View File

@ -76,7 +76,7 @@ void CMasternodeSync::SwitchToNextAsset()
nCurrentAsset = MASTERNODE_SYNC_FINISHED; nCurrentAsset = MASTERNODE_SYNC_FINISHED;
uiInterface.NotifyAdditionalDataSyncProgressChanged(1); uiInterface.NotifyAdditionalDataSyncProgressChanged(1);
connman.ForEachNode(CConnman::AllNodes, [](CNode* pnode) { connman.ForEachNode(CConnman::AllNodes, [](const CNode* pnode) {
netfulfilledman->AddFulfilledRequest(pnode->addr, "full-sync"); netfulfilledman->AddFulfilledRequest(pnode->addr, "full-sync");
}); });
LogPrintf("CMasternodeSync::SwitchToNextAsset -- Sync has finished\n"); LogPrintf("CMasternodeSync::SwitchToNextAsset -- Sync has finished\n");
@ -260,7 +260,7 @@ void CMasternodeSync::ProcessTick()
} }
// request votes on per-obj basis from each node // request votes on per-obj basis from each node
for (auto& pnode : vNodesCopy) { for (const auto& pnode : vNodesCopy) {
if(!netfulfilledman->HasFulfilledRequest(pnode->addr, "governance-sync")) { if(!netfulfilledman->HasFulfilledRequest(pnode->addr, "governance-sync")) {
continue; // to early for this node continue; // to early for this node
} }

View File

@ -1262,22 +1262,22 @@ static void protx_list_help(const JSONRPCRequest& request)
} }
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
static bool CheckWalletOwnsKey(CWallet* pwallet, const CKeyID& keyID) { static bool CheckWalletOwnsKey(const CWallet* const pwallet, const CKeyID& keyID) {
if (!pwallet) { if (!pwallet) {
return false; return false;
} }
LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan(); const LegacyScriptPubKeyMan* const spk_man = pwallet->GetLegacyScriptPubKeyMan();
if (!spk_man) { if (!spk_man) {
return false; return false;
} }
return spk_man->HaveKey(keyID); return spk_man->HaveKey(keyID);
} }
static bool CheckWalletOwnsScript(CWallet* pwallet, const CScript& script) { static bool CheckWalletOwnsScript(const CWallet* const pwallet, const CScript& script) {
if (!pwallet) { if (!pwallet) {
return false; return false;
} }
LegacyScriptPubKeyMan* spk_man = pwallet->GetLegacyScriptPubKeyMan(); const LegacyScriptPubKeyMan* const spk_man = pwallet->GetLegacyScriptPubKeyMan();
if (!spk_man) { if (!spk_man) {
return false; return false;
} }
@ -1292,7 +1292,7 @@ static bool CheckWalletOwnsScript(CWallet* pwallet, const CScript& script) {
} }
#endif #endif
static UniValue BuildDMNListEntry(CWallet* pwallet, const CDeterministicMN& dmn, CMasternodeMetaMan& mn_metaman, bool detailed, const ChainstateManager& chainman, const CBlockIndex* pindex = nullptr) static UniValue BuildDMNListEntry(const CWallet* const pwallet, const CDeterministicMN& dmn, CMasternodeMetaMan& mn_metaman, bool detailed, const ChainstateManager& chainman, const CBlockIndex* pindex = nullptr)
{ {
if (!detailed) { if (!detailed) {
return dmn.proTxHash.ToString(); return dmn.proTxHash.ToString();

View File

@ -602,8 +602,8 @@ static UniValue masternodelist(const JSONRPCRequest& request, ChainstateManager&
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
auto mnList = node.dmnman->GetListAtChainTip(); const auto mnList = node.dmnman->GetListAtChainTip();
auto dmnToStatus = [&](auto& dmn) { const auto dmnToStatus = [&](const auto& dmn) {
if (mnList.IsMNValid(dmn)) { if (mnList.IsMNValid(dmn)) {
return "ENABLED"; return "ENABLED";
} }
@ -612,7 +612,7 @@ static UniValue masternodelist(const JSONRPCRequest& request, ChainstateManager&
} }
return "UNKNOWN"; return "UNKNOWN";
}; };
auto dmnToLastPaidTime = [&](auto& dmn) { const auto dmnToLastPaidTime = [&](const auto& dmn) {
if (dmn.pdmnState->nLastPaidHeight == 0) { if (dmn.pdmnState->nLastPaidHeight == 0) {
return (int)0; return (int)0;
} }
@ -622,9 +622,9 @@ static UniValue masternodelist(const JSONRPCRequest& request, ChainstateManager&
return (int)pindex->nTime; return (int)pindex->nTime;
}; };
bool showRecentMnsOnly = strMode == "recent"; const bool showRecentMnsOnly = strMode == "recent";
bool showEvoOnly = strMode == "evo"; const bool showEvoOnly = strMode == "evo";
int tipHeight = WITH_LOCK(cs_main, return chainman.ActiveChain().Tip()->nHeight); const int tipHeight = WITH_LOCK(cs_main, return chainman.ActiveChain().Tip()->nHeight);
mnList.ForEachMN(false, [&](auto& dmn) { mnList.ForEachMN(false, [&](auto& dmn) {
if (showRecentMnsOnly && mnList.IsMNPoSeBanned(dmn)) { if (showRecentMnsOnly && mnList.IsMNPoSeBanned(dmn)) {
if (tipHeight - dmn.pdmnState->GetBannedHeight() > Params().GetConsensus().nSuperblockCycle) { if (tipHeight - dmn.pdmnState->GetBannedHeight() > Params().GetConsensus().nSuperblockCycle) {

View File

@ -61,7 +61,7 @@ class StatsdClient {
static void cleanup(std::string& key); static void cleanup(std::string& key);
protected: protected:
std::unique_ptr<struct _StatsdClientData> d; const std::unique_ptr<struct _StatsdClientData> d;
}; };
} // namespace statsd } // namespace statsd