Skip to content

Commit

Permalink
Directly use deterministicMNManager in some places
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Dec 31, 2018
1 parent 45f34e1 commit 1ff2418
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/governance-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/instantx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1ff2418

Please sign in to comment.