From 1ff241881fd1b418a3f32f83433b75bbf33e1f76 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Mon, 17 Dec 2018 14:34:50 +0100 Subject: [PATCH] Directly use deterministicMNManager in some places --- src/governance-object.cpp | 11 ++++++++--- src/instantx.cpp | 4 +++- src/rpc/governance.cpp | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/governance-object.cpp b/src/governance-object.cpp index 5eaba3c54e22e..4ea1bc5afd521 100644 --- a/src/governance-object.cpp +++ b/src/governance-object.cpp @@ -116,7 +116,9 @@ bool CGovernanceObject::ProcessVote(CNode* pfrom, return false; } - if (!mnodeman.Has(vote.GetMasternodeOutpoint())) { + auto mnList = deterministicMNManager->GetListAtChainTip(); + + if (!mnList.HasValidMNByCollateral(vote.GetMasternodeOutpoint())) { std::ostringstream ostr; ostr << "CGovernanceObject::ProcessVote -- Masternode " << vote.GetMasternodeOutpoint().ToStringShort() << " not found"; exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING); @@ -212,9 +214,11 @@ void CGovernanceObject::ClearMasternodeVotes() { LOCK(cs); + auto mnList = deterministicMNManager->GetListAtChainTip(); + vote_m_it it = mapCurrentMNVotes.begin(); while (it != mapCurrentMNVotes.end()) { - if (!mnodeman.Has(it->first)) { + if (!mnList.HasValidMNByCollateral(it->first)) { fileVotes.RemoveVotesFromMasternode(it->first); mapCurrentMNVotes.erase(it++); } else { @@ -812,6 +816,7 @@ void CGovernanceObject::UpdateSentinelVariables() void CGovernanceObject::CheckOrphanVotes(CConnman& connman) { int64_t nNow = GetAdjustedTime(); + auto mnList = deterministicMNManager->GetListAtChainTip(); const vote_cmm_t::list_t& listVotes = cmmapOrphanVotes.GetItemList(); vote_cmm_t::list_cit it = listVotes.begin(); while (it != listVotes.end()) { @@ -821,7 +826,7 @@ void CGovernanceObject::CheckOrphanVotes(CConnman& connman) const CGovernanceVote& vote = pairVote.first; if (pairVote.second < nNow) { fRemove = true; - } else if (!mnodeman.Has(vote.GetMasternodeOutpoint())) { + } else if (!mnList.HasValidMNByCollateral(vote.GetMasternodeOutpoint())) { ++it; continue; } diff --git a/src/instantx.cpp b/src/instantx.cpp index db2e2cc0eab46..d97f163a20257 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -1029,7 +1029,9 @@ bool CTxLockRequest::IsSimple() const bool CTxLockVote::IsValid(CNode* pnode, CConnman& connman) const { - if (!mnodeman.Has(outpointMasternode)) { + auto mnList = deterministicMNManager->GetListAtChainTip(); + + if (!mnList.HasValidMNByCollateral(outpointMasternode)) { LogPrint("instantsend", "CTxLockVote::IsValid -- Unknown masternode %s\n", outpointMasternode.ToStringShort()); mnodeman.AskForMN(pnode, outpointMasternode, connman); return false; diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index 4a5b8db8dbbe3..16ad1c891d7be 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -261,7 +261,8 @@ UniValue gobject_submit(const JSONRPCRequest& request) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Must wait for client to sync with masternode network. Try again in a minute or so."); } - bool fMnFound = mnodeman.Has(activeMasternodeInfo.outpoint); + auto mnList = deterministicMNManager->GetListAtChainTip(); + bool fMnFound = mnList.HasValidMNByCollateral(activeMasternodeInfo.outpoint); DBG( std::cout << "gobject: submit activeMasternodeInfo.keyIDOperator = " << activeMasternodeInfo.legacyKeyIDOperator.ToString() << ", outpoint = " << activeMasternodeInfo.outpoint.ToStringShort()