Remove a few uses of mnodeman from governance code

And remove them with direct use of deterministicMNManager
This commit is contained in:
Alexander Block 2018-12-17 15:39:21 +01:00
parent 14d8ce03c0
commit 2b2e4f45da
3 changed files with 13 additions and 25 deletions

View File

@ -123,9 +123,6 @@ bool CGovernanceObject::ProcessVote(CNode* pfrom,
ostr << "CGovernanceObject::ProcessVote -- Masternode " << vote.GetMasternodeOutpoint().ToStringShort() << " not found";
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING);
if (cmmapOrphanVotes.Insert(vote.GetMasternodeOutpoint(), vote_time_pair_t(vote, GetAdjustedTime() + GOVERNANCE_ORPHAN_EXPIRATION_TIME))) {
if (pfrom) {
mnodeman.AskForMN(pfrom, vote.GetMasternodeOutpoint(), connman);
}
LogPrintf("%s\n", ostr.str());
} else {
LogPrint("gobject", "%s\n", ostr.str());
@ -556,9 +553,11 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMast
return true;
}
auto mnList = deterministicMNManager->GetListAtChainTip();
std::string strOutpoint = masternodeOutpoint.ToStringShort();
masternode_info_t infoMn;
if (!mnodeman.GetMasternodeInfo(masternodeOutpoint, infoMn)) {
auto dmn = mnList.GetValidMNByCollateral(masternodeOutpoint);
if (!dmn) {
CMasternode::CollateralStatus err = CMasternode::CheckCollateral(masternodeOutpoint, CKeyID());
if (err == CMasternode::COLLATERAL_UTXO_NOT_FOUND) {
strError = "Failed to find Masternode UTXO, missing masternode=" + strOutpoint + "\n";
@ -576,17 +575,10 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMast
}
// Check that we have a valid MN signature
if (deterministicMNManager->IsDIP3Active()) {
if (!CheckSignature(infoMn.blsPubKeyOperator)) {
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.blsPubKeyOperator.ToString();
if (!CheckSignature(dmn->pdmnState->pubKeyOperator)) {
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey = " + dmn->pdmnState->pubKeyOperator.ToString();
return false;
}
} else {
if (!CheckSignature(infoMn.legacyKeyIDOperator)) {
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.legacyKeyIDOperator.ToString();
return false;
}
}
return true;
}
@ -783,7 +775,7 @@ void CGovernanceObject::UpdateSentinelVariables()
{
// CALCULATE MINIMUM SUPPORT LEVELS REQUIRED
int nMnCount = mnodeman.CountEnabled();
int nMnCount = (int)deterministicMNManager->GetListAtChainTip().GetValidMNsCount();
if (nMnCount == 0) return;
// CALCULATE THE MINUMUM VOTE COUNT REQUIRED FOR FULL SIGNAL

View File

@ -256,20 +256,16 @@ bool CGovernanceVote::IsValid(bool useVotingKey) const
return false;
}
masternode_info_t infoMn;
if (!mnodeman.GetMasternodeInfo(masternodeOutpoint, infoMn)) {
auto dmn = deterministicMNManager->GetListAtChainTip().GetValidMNByCollateral(masternodeOutpoint);
if (!dmn) {
LogPrint("gobject", "CGovernanceVote::IsValid -- Unknown Masternode - %s\n", masternodeOutpoint.ToStringShort());
return false;
}
if (useVotingKey) {
return CheckSignature(infoMn.keyIDVoting);
return CheckSignature(dmn->pdmnState->keyIDVoting);
} else {
if (deterministicMNManager->IsDIP3Active()) {
return CheckSignature(infoMn.blsPubKeyOperator);
} else {
return CheckSignature(infoMn.legacyKeyIDOperator);
}
return CheckSignature(dmn->pdmnState->pubKeyOperator);
}
}

View File

@ -1079,7 +1079,7 @@ int CGovernanceManager::RequestGovernanceObjectVotes(const std::vector<CNode*>&
int nMaxObjRequestsPerNode = 1;
size_t nProjectedVotes = 2000;
if (Params().NetworkIDString() != CBaseChainParams::MAIN) {
nMaxObjRequestsPerNode = std::max(1, int(nProjectedVotes / std::max(1, mnodeman.size())));
nMaxObjRequestsPerNode = std::max(1, int(nProjectedVotes / std::max(1, (int)deterministicMNManager->GetListAtChainTip().GetValidMNsCount())));
}
{