diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index 1e74c82cdd5d3..e5193d02f2aee 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -259,6 +259,13 @@ class CDeterministicMNList }); } + [[nodiscard]] size_t GetWeightedMNsCount() const + { + return std::accumulate(mnMap.begin(), mnMap.end(), 0, [this](auto res, const auto& p) { + return res + GetMnType(p.second->nType).voting_weight; + }); + } + /** * Execute a callback on all masternodes in the mnList. This will pass a reference * of each masternode to the callback function. This should be preferred over ForEachMNShared. diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index ddf5515ed7c45..55c2ceb1bdc6e 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -561,9 +561,9 @@ std::optional CGovernanceManager::CreateSuperblockCandidate(int nHe if (HasAlreadyVotedFundingTrigger()) return std::nullopt; // A proposal is considered passing if (YES votes) >= (Total Weight of Masternodes / 10), - // count total valid (ENABLED) masternodes to determine passing threshold. + // count total registered masternodes to determine passing threshold. const auto mnList = deterministicMNManager->GetListAtChainTip(); - const int nWeightedMnCount = mnList.GetValidWeightedMNsCount(); + const int nWeightedMnCount = mnList.GetWeightedMNsCount(); const int nAbsVoteReq = std::max(Params().GetConsensus().nGovernanceMinQuorum, nWeightedMnCount / 10); // Use std::vector of std::shared_ptr because CGovernanceObject doesn't support move operations (needed for sorting the vector later) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 8cbbe58bcf62a..c188da06c6bf3 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -345,9 +345,9 @@ void GovernanceList::updateProposalList() { if (this->clientModel) { // A proposal is considered passing if (YES votes - NO votes) >= (Total Weight of Masternodes / 10), - // count total valid (ENABLED) masternodes to determine passing threshold. + // count total registered masternodes to determine passing threshold. // Need to query number of masternodes here with access to clientModel. - const int nWeightedMnCount = clientModel->getMasternodeList().GetValidWeightedMNsCount(); + const int nWeightedMnCount = clientModel->getMasternodeList().GetWeightedMNsCount(); const int nAbsVoteReq = std::max(Params().GetConsensus().nGovernanceMinQuorum, nWeightedMnCount / 10); proposalModel->setVotingParams(nAbsVoteReq); diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index 6f15fc69cead4..030785da2fece 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -1046,7 +1046,7 @@ static UniValue getgovernanceinfo(const JSONRPCRequest& request) obj.pushKV("superblockmaturitywindow", Params().GetConsensus().nSuperblockMaturityWindow); obj.pushKV("lastsuperblock", nLastSuperblock); obj.pushKV("nextsuperblock", nNextSuperblock); - obj.pushKV("fundingthreshold", int(deterministicMNManager->GetListAtChainTip().GetValidWeightedMNsCount() / 10)); + obj.pushKV("fundingthreshold", int(deterministicMNManager->GetListAtChainTip().GetWeightedMNsCount() / 10)); return obj; }