Added CleanAndRemove for Proposal votes
This commit is contained in:
parent
2b949e08a8
commit
edaf479063
@ -465,8 +465,10 @@ std::vector<CBudgetProposal*> CBudgetManager::GetAllProposals()
|
|||||||
std::map<uint256, CBudgetProposal>::iterator it2 = mapProposals.begin();
|
std::map<uint256, CBudgetProposal>::iterator it2 = mapProposals.begin();
|
||||||
while(it2 != mapProposals.end())
|
while(it2 != mapProposals.end())
|
||||||
{
|
{
|
||||||
|
(*it).second.CleanAndRemove();
|
||||||
|
|
||||||
CBudgetProposal* prop = &((*it2).second);
|
CBudgetProposal* prop = &((*it2).second);
|
||||||
ret.push_back(prop);
|
ret.push_back(prop);
|
||||||
|
|
||||||
it2++;
|
it2++;
|
||||||
}
|
}
|
||||||
@ -483,6 +485,7 @@ std::vector<CBudgetProposal*> CBudgetManager::GetBudget()
|
|||||||
|
|
||||||
std::map<uint256, CBudgetProposal>::iterator it = mapProposals.begin();
|
std::map<uint256, CBudgetProposal>::iterator it = mapProposals.begin();
|
||||||
while(it != mapProposals.end()){
|
while(it != mapProposals.end()){
|
||||||
|
(*it).second.CleanAndRemove();
|
||||||
mapList.insert(make_pair((*it).second.GetHash(), (*it).second.GetYeas()));
|
mapList.insert(make_pair((*it).second.GetHash(), (*it).second.GetYeas()));
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
@ -953,6 +956,21 @@ void CBudgetProposal::AddOrUpdateVote(CBudgetVote& vote)
|
|||||||
mapVotes[hash] = vote;
|
mapVotes[hash] = vote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If masternode voted for a proposal, but is now invalid -- remove the vote
|
||||||
|
void CBudgetProposal::CleanAndRemove()
|
||||||
|
{
|
||||||
|
std::map<uint256, CBudgetVote>::iterator it = mapVotes.begin();
|
||||||
|
|
||||||
|
while(it != mapVotes.end()) {
|
||||||
|
if ((*it).second.SignatureValid())
|
||||||
|
{
|
||||||
|
++it;
|
||||||
|
} else {
|
||||||
|
mapVotes.erase(it++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double CBudgetProposal::GetRatio()
|
double CBudgetProposal::GetRatio()
|
||||||
{
|
{
|
||||||
int yeas = 0;
|
int yeas = 0;
|
||||||
|
@ -385,6 +385,8 @@ public:
|
|||||||
void SetAllotted(int64_t nAllotedIn) {nAlloted = nAllotedIn;}
|
void SetAllotted(int64_t nAllotedIn) {nAlloted = nAllotedIn;}
|
||||||
int64_t GetAllotted() {return nAlloted;}
|
int64_t GetAllotted() {return nAlloted;}
|
||||||
|
|
||||||
|
void CleanAndRemove();
|
||||||
|
|
||||||
uint256 GetHash(){
|
uint256 GetHash(){
|
||||||
/*
|
/*
|
||||||
vin is not included on purpose
|
vin is not included on purpose
|
||||||
|
Loading…
Reference in New Issue
Block a user