mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +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";
|
ostr << "CGovernanceObject::ProcessVote -- Masternode " << vote.GetMasternodeOutpoint().ToStringShort() << " not found";
|
||||||
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING);
|
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_WARNING);
|
||||||
if (cmmapOrphanVotes.Insert(vote.GetMasternodeOutpoint(), vote_time_pair_t(vote, GetAdjustedTime() + GOVERNANCE_ORPHAN_EXPIRATION_TIME))) {
|
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());
|
LogPrintf("%s\n", ostr.str());
|
||||||
} else {
|
} else {
|
||||||
LogPrint("gobject", "%s\n", ostr.str());
|
LogPrint("gobject", "%s\n", ostr.str());
|
||||||
@ -556,9 +553,11 @@ bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingMast
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto mnList = deterministicMNManager->GetListAtChainTip();
|
||||||
|
|
||||||
std::string strOutpoint = masternodeOutpoint.ToStringShort();
|
std::string strOutpoint = masternodeOutpoint.ToStringShort();
|
||||||
masternode_info_t infoMn;
|
auto dmn = mnList.GetValidMNByCollateral(masternodeOutpoint);
|
||||||
if (!mnodeman.GetMasternodeInfo(masternodeOutpoint, infoMn)) {
|
if (!dmn) {
|
||||||
CMasternode::CollateralStatus err = CMasternode::CheckCollateral(masternodeOutpoint, CKeyID());
|
CMasternode::CollateralStatus err = CMasternode::CheckCollateral(masternodeOutpoint, CKeyID());
|
||||||
if (err == CMasternode::COLLATERAL_UTXO_NOT_FOUND) {
|
if (err == CMasternode::COLLATERAL_UTXO_NOT_FOUND) {
|
||||||
strError = "Failed to find Masternode UTXO, missing masternode=" + strOutpoint + "\n";
|
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
|
// Check that we have a valid MN signature
|
||||||
if (deterministicMNManager->IsDIP3Active()) {
|
if (!CheckSignature(dmn->pdmnState->pubKeyOperator)) {
|
||||||
if (!CheckSignature(infoMn.blsPubKeyOperator)) {
|
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey = " + dmn->pdmnState->pubKeyOperator.ToString();
|
||||||
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.blsPubKeyOperator.ToString();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!CheckSignature(infoMn.legacyKeyIDOperator)) {
|
|
||||||
strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey id = " + infoMn.legacyKeyIDOperator.ToString();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -783,7 +775,7 @@ void CGovernanceObject::UpdateSentinelVariables()
|
|||||||
{
|
{
|
||||||
// CALCULATE MINIMUM SUPPORT LEVELS REQUIRED
|
// CALCULATE MINIMUM SUPPORT LEVELS REQUIRED
|
||||||
|
|
||||||
int nMnCount = mnodeman.CountEnabled();
|
int nMnCount = (int)deterministicMNManager->GetListAtChainTip().GetValidMNsCount();
|
||||||
if (nMnCount == 0) return;
|
if (nMnCount == 0) return;
|
||||||
|
|
||||||
// CALCULATE THE MINUMUM VOTE COUNT REQUIRED FOR FULL SIGNAL
|
// CALCULATE THE MINUMUM VOTE COUNT REQUIRED FOR FULL SIGNAL
|
||||||
|
@ -256,20 +256,16 @@ bool CGovernanceVote::IsValid(bool useVotingKey) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
masternode_info_t infoMn;
|
auto dmn = deterministicMNManager->GetListAtChainTip().GetValidMNByCollateral(masternodeOutpoint);
|
||||||
if (!mnodeman.GetMasternodeInfo(masternodeOutpoint, infoMn)) {
|
if (!dmn) {
|
||||||
LogPrint("gobject", "CGovernanceVote::IsValid -- Unknown Masternode - %s\n", masternodeOutpoint.ToStringShort());
|
LogPrint("gobject", "CGovernanceVote::IsValid -- Unknown Masternode - %s\n", masternodeOutpoint.ToStringShort());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useVotingKey) {
|
if (useVotingKey) {
|
||||||
return CheckSignature(infoMn.keyIDVoting);
|
return CheckSignature(dmn->pdmnState->keyIDVoting);
|
||||||
} else {
|
} else {
|
||||||
if (deterministicMNManager->IsDIP3Active()) {
|
return CheckSignature(dmn->pdmnState->pubKeyOperator);
|
||||||
return CheckSignature(infoMn.blsPubKeyOperator);
|
|
||||||
} else {
|
|
||||||
return CheckSignature(infoMn.legacyKeyIDOperator);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,7 +1079,7 @@ int CGovernanceManager::RequestGovernanceObjectVotes(const std::vector<CNode*>&
|
|||||||
int nMaxObjRequestsPerNode = 1;
|
int nMaxObjRequestsPerNode = 1;
|
||||||
size_t nProjectedVotes = 2000;
|
size_t nProjectedVotes = 2000;
|
||||||
if (Params().NetworkIDString() != CBaseChainParams::MAIN) {
|
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