More cleanup

- AddProposal -> AddGovernanceObject
- mapOrphanMasternodeBudgetVotes -> mapOrphanVotes
- UpdateProposal -> UpdateGovernanceObject
This commit is contained in:
Evan Duffield 2016-05-23 10:58:39 -07:00
parent 860d29f9c4
commit 623ac049e2
3 changed files with 21 additions and 21 deletions

View File

@ -94,28 +94,28 @@ void CGovernanceManager::CheckOrphanVotes()
LOCK(cs);
std::string strError = "";
std::map<uint256, CGovernanceVote>::iterator it1 = mapOrphanMasternodeBudgetVotes.begin();
while(it1 != mapOrphanMasternodeBudgetVotes.end()){
if(UpdateProposal(((*it1).second), NULL, strError)){
std::map<uint256, CGovernanceVote>::iterator it1 = mapOrphanVotes.begin();
while(it1 != mapOrphanVotes.end()){
if(UpdateGovernanceObject(((*it1).second), NULL, strError)){
LogPrintf("CGovernanceManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n");
mapOrphanMasternodeBudgetVotes.erase(it1++);
mapOrphanVotes.erase(it1++);
} else {
++it1;
}
}
}
bool CGovernanceManager::AddProposal(CGovernanceObject& budgetProposal)
bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& budgetProposal)
{
LOCK(cs);
std::string 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;
}
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;
}
@ -285,7 +285,7 @@ void CGovernanceManager::NewBlock()
// }
// CGovernanceObject budgetProposal((*it4));
// if(AddProposal(budgetProposal)) {(*it4).Relay();}
// if(AddGovernanceObject(budgetProposal)) {(*it4).Relay();}
// LogPrintf("mprop (immature) - new budget - %s\n", (*it4).GetHash().ToString());
// it4 = vecImmatureBudgetProposals.erase(it4);
@ -346,7 +346,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
return;
}
if(AddProposal(budgetProposalBroadcast))
if(AddGovernanceObject(budgetProposalBroadcast))
{
budgetProposalBroadcast.Relay();
}
@ -385,7 +385,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
}
std::string strError = "";
if(UpdateProposal(vote, pfrom, strError)) {
if(UpdateGovernanceObject(vote, pfrom, strError)) {
vote.Relay();
masternodeSync.AddedBudgetItem(vote.GetHash());
}
@ -482,7 +482,7 @@ void CGovernanceManager::Sync(CNode* pfrom, uint256 nProp)
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);
@ -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
if(!masternodeSync.IsSynced()) return false;
LogPrintf("CGovernanceManager::UpdateProposal - Unknown proposal %d, asking for source proposal\n", vote.nParentHash.ToString());
mapOrphanMasternodeBudgetVotes[vote.nParentHash] = vote;
LogPrintf("CGovernanceManager::UpdateGovernanceObject - Unknown proposal %d, asking for source proposal\n", vote.nParentHash.ToString());
mapOrphanVotes[vote.nParentHash] = vote;
if(!askedForSourceProposalOrBudget.count(vote.nParentHash)){
pfrom->PushMessage(NetMsgType::MNGOVERNANCEVOTESYNC, vote.nParentHash);

View File

@ -77,7 +77,7 @@ public:
// todo - 12.1 - move to private for better encapsulation
std::map<uint256, int> mapSeenGovernanceObjects;
std::map<uint256, int> mapSeenVotes;
std::map<uint256, CGovernanceVote> mapOrphanMasternodeBudgetVotes;
std::map<uint256, CGovernanceVote> mapOrphanVotes;
std::map<uint256, CGovernanceVote> mapVotes;
CGovernanceManager() {
@ -114,8 +114,8 @@ public:
int CountMatchingVotes(int nVoteSignalIn, int nVoteOutcomeIn);
bool IsBudgetPaymentBlock(int nBlockHeight);
bool AddProposal(CGovernanceObject& budgetProposal);
bool UpdateProposal(CGovernanceVote& vote, CNode* pfrom, std::string& strError);
bool AddGovernanceObject (CGovernanceObject& budgetProposal);
bool UpdateGovernanceObject(CGovernanceVote& vote, CNode* pfrom, std::string& strError);
bool AddOrUpdateVote(CGovernanceVote& vote, std::string& strError);
bool PropExists(uint256 nHash);
std::string GetRequiredPaymentsString(int nBlockHeight);
@ -130,7 +130,7 @@ public:
mapObjects.clear();
mapSeenGovernanceObjects.clear();
mapSeenVotes.clear();
mapOrphanMasternodeBudgetVotes.clear();
mapOrphanVotes.clear();
}
std::string ToString() const;
@ -140,7 +140,7 @@ public:
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(mapSeenGovernanceObjects);
READWRITE(mapSeenVotes);
READWRITE(mapOrphanMasternodeBudgetVotes);
READWRITE(mapOrphanVotes);
READWRITE(mapObjects);
READWRITE(mapVotes);
}

View File

@ -204,7 +204,7 @@ UniValue mngovernance(const UniValue& params, bool fHelp)
governance.mapSeenGovernanceObjects.insert(make_pair(budgetProposalBroadcast.GetHash(), SEEN_OBJECT_IS_VALID));
budgetProposalBroadcast.Relay();
governance.AddProposal(budgetProposalBroadcast);
governance.AddGovernanceObject(budgetProposalBroadcast);
return budgetProposalBroadcast.GetHash().ToString();
@ -283,7 +283,7 @@ UniValue mngovernance(const UniValue& params, bool fHelp)
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));
vote.Relay();
success++;
@ -467,7 +467,7 @@ UniValue voteraw(const UniValue& params, bool fHelp)
}
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));
vote.Relay();
return "Voted successfully";