mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Remove a few uses of mnodeman from governance code
And remove them with direct use of deterministicMNManager
This commit is contained in:
parent
14d8ce03c0
commit
2b2e4f45da
@ -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,16 +575,9 @@ 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();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!CheckSignature(infoMn.legacyKeyIDOperator)) {
|
||||
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.legacyKeyIDOperator.ToString();
|
||||
return false;
|
||||
}
|
||||
if (!CheckSignature(dmn->pdmnState->pubKeyOperator)) {
|
||||
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey = " + dmn->pdmnState->pubKeyOperator.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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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())));
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user