mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
More cleanup
- AddProposal -> AddGovernanceObject - mapOrphanMasternodeBudgetVotes -> mapOrphanVotes - UpdateProposal -> UpdateGovernanceObject
This commit is contained in:
parent
860d29f9c4
commit
623ac049e2
@ -94,28 +94,28 @@ void CGovernanceManager::CheckOrphanVotes()
|
|||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
std::map<uint256, CGovernanceVote>::iterator it1 = mapOrphanMasternodeBudgetVotes.begin();
|
std::map<uint256, CGovernanceVote>::iterator it1 = mapOrphanVotes.begin();
|
||||||
while(it1 != mapOrphanMasternodeBudgetVotes.end()){
|
while(it1 != mapOrphanVotes.end()){
|
||||||
if(UpdateProposal(((*it1).second), NULL, strError)){
|
if(UpdateGovernanceObject(((*it1).second), NULL, strError)){
|
||||||
LogPrintf("CGovernanceManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n");
|
LogPrintf("CGovernanceManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n");
|
||||||
mapOrphanMasternodeBudgetVotes.erase(it1++);
|
mapOrphanVotes.erase(it1++);
|
||||||
} else {
|
} else {
|
||||||
++it1;
|
++it1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGovernanceManager::AddProposal(CGovernanceObject& budgetProposal)
|
bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& budgetProposal)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
if(!budgetProposal.IsValid(pCurrentBlockIndex, strError)) {
|
if(!budgetProposal.IsValid(pCurrentBlockIndex, strError)) {
|
||||||
LogPrintf("CGovernanceManager::AddProposal - invalid governance object - %s\n", strError);
|
LogPrintf("CGovernanceManager::AddGovernanceObject - invalid governance object - %s\n", strError);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mapObjects.count(budgetProposal.GetHash())) {
|
if(mapObjects.count(budgetProposal.GetHash())) {
|
||||||
LogPrintf("CGovernanceManager::AddProposal - already have governance object - %s\n", strError);
|
LogPrintf("CGovernanceManager::AddGovernanceObject - already have governance object - %s\n", strError);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ void CGovernanceManager::NewBlock()
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// CGovernanceObject budgetProposal((*it4));
|
// CGovernanceObject budgetProposal((*it4));
|
||||||
// if(AddProposal(budgetProposal)) {(*it4).Relay();}
|
// if(AddGovernanceObject(budgetProposal)) {(*it4).Relay();}
|
||||||
|
|
||||||
// LogPrintf("mprop (immature) - new budget - %s\n", (*it4).GetHash().ToString());
|
// LogPrintf("mprop (immature) - new budget - %s\n", (*it4).GetHash().ToString());
|
||||||
// it4 = vecImmatureBudgetProposals.erase(it4);
|
// it4 = vecImmatureBudgetProposals.erase(it4);
|
||||||
@ -346,7 +346,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(AddProposal(budgetProposalBroadcast))
|
if(AddGovernanceObject(budgetProposalBroadcast))
|
||||||
{
|
{
|
||||||
budgetProposalBroadcast.Relay();
|
budgetProposalBroadcast.Relay();
|
||||||
}
|
}
|
||||||
@ -385,7 +385,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
if(UpdateProposal(vote, pfrom, strError)) {
|
if(UpdateGovernanceObject(vote, pfrom, strError)) {
|
||||||
vote.Relay();
|
vote.Relay();
|
||||||
masternodeSync.AddedBudgetItem(vote.GetHash());
|
masternodeSync.AddedBudgetItem(vote.GetHash());
|
||||||
}
|
}
|
||||||
@ -482,7 +482,7 @@ void CGovernanceManager::Sync(CNode* pfrom, uint256 nProp)
|
|||||||
LogPrintf("CGovernanceManager::Sync - sent %d items\n", nInvCount);
|
LogPrintf("CGovernanceManager::Sync - sent %d items\n", nInvCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGovernanceManager::UpdateProposal(CGovernanceVote& vote, CNode* pfrom, std::string& strError)
|
bool CGovernanceManager::UpdateGovernanceObject(CGovernanceVote& vote, CNode* pfrom, std::string& strError)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
@ -492,8 +492,8 @@ bool CGovernanceManager::UpdateProposal(CGovernanceVote& vote, CNode* pfrom, std
|
|||||||
// otherwise we'll think a full sync succeeded when they return a result
|
// otherwise we'll think a full sync succeeded when they return a result
|
||||||
if(!masternodeSync.IsSynced()) return false;
|
if(!masternodeSync.IsSynced()) return false;
|
||||||
|
|
||||||
LogPrintf("CGovernanceManager::UpdateProposal - Unknown proposal %d, asking for source proposal\n", vote.nParentHash.ToString());
|
LogPrintf("CGovernanceManager::UpdateGovernanceObject - Unknown proposal %d, asking for source proposal\n", vote.nParentHash.ToString());
|
||||||
mapOrphanMasternodeBudgetVotes[vote.nParentHash] = vote;
|
mapOrphanVotes[vote.nParentHash] = vote;
|
||||||
|
|
||||||
if(!askedForSourceProposalOrBudget.count(vote.nParentHash)){
|
if(!askedForSourceProposalOrBudget.count(vote.nParentHash)){
|
||||||
pfrom->PushMessage(NetMsgType::MNGOVERNANCEVOTESYNC, vote.nParentHash);
|
pfrom->PushMessage(NetMsgType::MNGOVERNANCEVOTESYNC, vote.nParentHash);
|
||||||
|
@ -77,7 +77,7 @@ public:
|
|||||||
// todo - 12.1 - move to private for better encapsulation
|
// todo - 12.1 - move to private for better encapsulation
|
||||||
std::map<uint256, int> mapSeenGovernanceObjects;
|
std::map<uint256, int> mapSeenGovernanceObjects;
|
||||||
std::map<uint256, int> mapSeenVotes;
|
std::map<uint256, int> mapSeenVotes;
|
||||||
std::map<uint256, CGovernanceVote> mapOrphanMasternodeBudgetVotes;
|
std::map<uint256, CGovernanceVote> mapOrphanVotes;
|
||||||
std::map<uint256, CGovernanceVote> mapVotes;
|
std::map<uint256, CGovernanceVote> mapVotes;
|
||||||
|
|
||||||
CGovernanceManager() {
|
CGovernanceManager() {
|
||||||
@ -114,8 +114,8 @@ public:
|
|||||||
int CountMatchingVotes(int nVoteSignalIn, int nVoteOutcomeIn);
|
int CountMatchingVotes(int nVoteSignalIn, int nVoteOutcomeIn);
|
||||||
|
|
||||||
bool IsBudgetPaymentBlock(int nBlockHeight);
|
bool IsBudgetPaymentBlock(int nBlockHeight);
|
||||||
bool AddProposal(CGovernanceObject& budgetProposal);
|
bool AddGovernanceObject (CGovernanceObject& budgetProposal);
|
||||||
bool UpdateProposal(CGovernanceVote& vote, CNode* pfrom, std::string& strError);
|
bool UpdateGovernanceObject(CGovernanceVote& vote, CNode* pfrom, std::string& strError);
|
||||||
bool AddOrUpdateVote(CGovernanceVote& vote, std::string& strError);
|
bool AddOrUpdateVote(CGovernanceVote& vote, std::string& strError);
|
||||||
bool PropExists(uint256 nHash);
|
bool PropExists(uint256 nHash);
|
||||||
std::string GetRequiredPaymentsString(int nBlockHeight);
|
std::string GetRequiredPaymentsString(int nBlockHeight);
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
mapObjects.clear();
|
mapObjects.clear();
|
||||||
mapSeenGovernanceObjects.clear();
|
mapSeenGovernanceObjects.clear();
|
||||||
mapSeenVotes.clear();
|
mapSeenVotes.clear();
|
||||||
mapOrphanMasternodeBudgetVotes.clear();
|
mapOrphanVotes.clear();
|
||||||
}
|
}
|
||||||
std::string ToString() const;
|
std::string ToString() const;
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public:
|
|||||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||||
READWRITE(mapSeenGovernanceObjects);
|
READWRITE(mapSeenGovernanceObjects);
|
||||||
READWRITE(mapSeenVotes);
|
READWRITE(mapSeenVotes);
|
||||||
READWRITE(mapOrphanMasternodeBudgetVotes);
|
READWRITE(mapOrphanVotes);
|
||||||
READWRITE(mapObjects);
|
READWRITE(mapObjects);
|
||||||
READWRITE(mapVotes);
|
READWRITE(mapVotes);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ UniValue mngovernance(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
governance.mapSeenGovernanceObjects.insert(make_pair(budgetProposalBroadcast.GetHash(), SEEN_OBJECT_IS_VALID));
|
governance.mapSeenGovernanceObjects.insert(make_pair(budgetProposalBroadcast.GetHash(), SEEN_OBJECT_IS_VALID));
|
||||||
budgetProposalBroadcast.Relay();
|
budgetProposalBroadcast.Relay();
|
||||||
governance.AddProposal(budgetProposalBroadcast);
|
governance.AddGovernanceObject(budgetProposalBroadcast);
|
||||||
|
|
||||||
return budgetProposalBroadcast.GetHash().ToString();
|
return budgetProposalBroadcast.GetHash().ToString();
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ UniValue mngovernance(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
|
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
if(governance.UpdateProposal(vote, NULL, strError)) {
|
if(governance.UpdateGovernanceObject(vote, NULL, strError)) {
|
||||||
governance.mapSeenVotes.insert(make_pair(vote.GetHash(), SEEN_OBJECT_IS_VALID));
|
governance.mapSeenVotes.insert(make_pair(vote.GetHash(), SEEN_OBJECT_IS_VALID));
|
||||||
vote.Relay();
|
vote.Relay();
|
||||||
success++;
|
success++;
|
||||||
@ -467,7 +467,7 @@ UniValue voteraw(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
if(governance.UpdateProposal(vote, NULL, strError)){
|
if(governance.UpdateGovernanceObject(vote, NULL, strError)){
|
||||||
governance.mapSeenVotes.insert(make_pair(vote.GetHash(), SEEN_OBJECT_IS_VALID));
|
governance.mapSeenVotes.insert(make_pair(vote.GetHash(), SEEN_OBJECT_IS_VALID));
|
||||||
vote.Relay();
|
vote.Relay();
|
||||||
return "Voted successfully";
|
return "Voted successfully";
|
||||||
|
Loading…
Reference in New Issue
Block a user