mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
fixed
This commit is contained in:
parent
b02d5260fd
commit
40adfbf2c9
@ -378,7 +378,6 @@ int CBudgetProposal::GetBlockStart()
|
||||
{
|
||||
std::map<int, int> mapList;
|
||||
|
||||
|
||||
std::map<uint256, CBudgetVote>::iterator it = mapVotes.begin();
|
||||
|
||||
while(it != mapVotes.end()) {
|
||||
@ -391,11 +390,10 @@ int CBudgetProposal::GetBlockStart()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//sort(mapList.begin(), mapList.end());
|
||||
//return myMap.begin()->second;
|
||||
|
||||
return 0;
|
||||
//sort the map and grab the highest count item
|
||||
std::vector<std::pair<int,int> > vecList(mapList.begin(), mapList.end());
|
||||
std::sort(vecList.begin(),vecList.end());
|
||||
return vecList.begin()->second;
|
||||
}
|
||||
|
||||
int CBudgetProposal::GetBlockEnd()
|
||||
@ -414,9 +412,10 @@ int CBudgetProposal::GetBlockEnd()
|
||||
}
|
||||
}
|
||||
|
||||
// sort(mapList.begin(), mapList.end());
|
||||
// return myMap.begin()->first;
|
||||
return 0;
|
||||
//sort the map and grab the highest count item
|
||||
std::vector<std::pair<int,int> > vecList(mapList.begin(), mapList.end());
|
||||
std::sort(vecList.begin(),vecList.end());
|
||||
return vecList.begin()->second;
|
||||
}
|
||||
|
||||
int64_t CBudgetProposal::GetAmount()
|
||||
@ -435,9 +434,10 @@ int64_t CBudgetProposal::GetAmount()
|
||||
}
|
||||
}
|
||||
|
||||
// sort(mapList.begin(), mapList.end());
|
||||
// return myMap.begin()->first;
|
||||
return 0;
|
||||
//sort the map and grab the highest count item
|
||||
std::vector<std::pair<int64_t,int> > vecList(mapList.begin(), mapList.end());
|
||||
std::sort(vecList.begin(),vecList.end());
|
||||
return vecList.begin()->second;
|
||||
}
|
||||
|
||||
CScript CBudgetProposal::GetPayee()
|
||||
@ -461,9 +461,10 @@ CScript CBudgetProposal::GetPayee()
|
||||
|
||||
}
|
||||
|
||||
// sort(mapList.begin(), mapList.end());
|
||||
// return myMap.begin()->first;
|
||||
return CScript();
|
||||
//sort the map and grab the highest count item
|
||||
std::vector<std::pair<CScript,int> > vecList(mapList.begin(), mapList.end());
|
||||
std::sort(vecList.begin(),vecList.end());
|
||||
return vecList.begin()->second;
|
||||
}
|
||||
|
||||
double CBudgetProposal::GetRatio()
|
||||
@ -536,39 +537,44 @@ int64_t CBudgetManager::GetTotalBudget()
|
||||
//Need to review this function
|
||||
std::vector<CBudgetProposal*> CBudgetManager::GetBudget()
|
||||
{
|
||||
// ------- Sort budgets by Yes Count
|
||||
|
||||
std::map<uint256, int> mapList;
|
||||
|
||||
/* std::map<uint256, CBudgetProposal>::iterator it = mapProposals.begin();
|
||||
while(it != mapProposals.end())
|
||||
uint256 hash = GetBudgetProposalHash((*it).second.strProposalName);
|
||||
mapList[hash] = (*it).second.GetYeas();
|
||||
}
|
||||
|
||||
//sort by yeas
|
||||
sort(mapList.begin(), mapList.end());
|
||||
|
||||
*/
|
||||
std::vector<CBudgetProposal*> ret;
|
||||
/*
|
||||
int64_t nBudgetAllocated = 0;
|
||||
int64_t nTotalBudget = GetTotalBudget();
|
||||
|
||||
std::map<uint256, CBudgetProposal>::iterator it = mapProposals.begin();
|
||||
while(it != mapProposals.end())
|
||||
{
|
||||
if(nTotalBudget == nBudgetAllocated){
|
||||
(*it).second.SetAllotted(0);
|
||||
} else if((*it).second.GetAmount() + nBudgetAllocated <= nTotalBudget()) {
|
||||
(*it).second..SetAllotted((*it).GetAmount());
|
||||
nBudgetAllocated += (*it).second.GetAmount();
|
||||
} else {
|
||||
//couldn't pay for the entire budget, so it'll be partially paid.
|
||||
(*it).second.SetAllotted(nTotalBudget - nBudgetAllocated);
|
||||
nBudgetAllocated = nTotalBudget;
|
||||
}
|
||||
mapList[GetBudgetProposalHash((*it).second.strProposalName)] = (*it).second.GetYeas();
|
||||
|
||||
//sort the map and grab the highest count item
|
||||
std::vector<std::pair<uint256,int> > vecList(mapList.begin(), mapList.end());
|
||||
std::sort(vecList.begin(),vecList.end());
|
||||
|
||||
// ------- Grab The Budgets In Order
|
||||
|
||||
std::vector<CBudgetProposal*> ret;
|
||||
|
||||
int64_t nBudgetAllocated = 0;
|
||||
int64_t nTotalBudget = GetTotalBudget();
|
||||
|
||||
std::map<uint256, CBudgetProposal>::iterator it2 = mapProposals.begin();
|
||||
while(it2 != mapProposals.end())
|
||||
{
|
||||
CBudgetProposal prop = (*it2).second;
|
||||
|
||||
if(nTotalBudget == nBudgetAllocated){
|
||||
prop.SetAllotted(0);
|
||||
} else if(prop.GetAmount() + nBudgetAllocated <= nTotalBudget) {
|
||||
prop.SetAllotted(prop.GetAmount());
|
||||
nBudgetAllocated += prop.GetAmount();
|
||||
} else {
|
||||
//couldn't pay for the entire budget, so it'll be partially paid.
|
||||
prop.SetAllotted(nTotalBudget - nBudgetAllocated);
|
||||
nBudgetAllocated = nTotalBudget;
|
||||
}
|
||||
|
||||
ret.push_back(&prop);
|
||||
}
|
||||
|
||||
ret.insert(make_pair((*it).second.strProposalName, &(*it)))
|
||||
}*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -143,8 +143,8 @@ public:
|
||||
int GetAbstains();
|
||||
int64_t GetAmount();
|
||||
|
||||
void SetAlloted(int64_t nAllotedIn) {nAlloted = nAllotedIn;}
|
||||
int64_t GetAlloted() {return nAlloted;}
|
||||
void SetAllotted(int64_t nAllotedIn) {nAlloted = nAllotedIn;}
|
||||
int64_t GetAllotted() {return nAlloted;}
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
|
@ -159,12 +159,12 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
if(prop == NULL) return "Unknown proposal name";
|
||||
|
||||
Object resultObj;
|
||||
int64_t nTotalAlloted = 0;
|
||||
int64_t nTotalAllotted = 0;
|
||||
|
||||
std::vector<CBudgetProposal*> winningProps = budget.GetBudget();
|
||||
BOOST_FOREACH(CBudgetProposal* prop, winningProps)
|
||||
{
|
||||
nTotalAlloted += prop->GetAlloted();
|
||||
nTotalAllotted += prop->GetAllotted();
|
||||
|
||||
CTxDestination address1;
|
||||
ExtractDestination(prop->GetPayee(), address1);
|
||||
@ -179,8 +179,8 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
bObj.push_back(Pair("Yeas", (int64_t)prop->GetYeas()));
|
||||
bObj.push_back(Pair("Nays", (int64_t)prop->GetNays()));
|
||||
bObj.push_back(Pair("Abstains", (int64_t)prop->GetAbstains()));
|
||||
bObj.push_back(Pair("Alloted", (int64_t)prop->GetAlloted()));
|
||||
bObj.push_back(Pair("TotalBudgetAlloted", nTotalAlloted));
|
||||
bObj.push_back(Pair("Alloted", (int64_t)prop->GetAllotted()));
|
||||
bObj.push_back(Pair("TotalBudgetAlloted", nTotalAllotted));
|
||||
resultObj.push_back(Pair("masternode", bObj));
|
||||
}
|
||||
|
||||
@ -211,7 +211,7 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
obj.push_back(Pair("Yeas", (int64_t)prop->GetYeas()));
|
||||
obj.push_back(Pair("Nays", (int64_t)prop->GetNays()));
|
||||
obj.push_back(Pair("Abstains", (int64_t)prop->GetAbstains()));
|
||||
obj.push_back(Pair("Alloted", (int64_t)prop->GetAlloted()));
|
||||
obj.push_back(Pair("Alloted", (int64_t)prop->GetAllotted()));
|
||||
|
||||
return obj;
|
||||
}
|
||||
@ -232,10 +232,10 @@ Value mnbudget(const Array& params, bool fHelp)
|
||||
|
||||
int c = 0;
|
||||
|
||||
/* map<uint256, CBudgetVote>::iterator it = prop->mapVotes.begin();
|
||||
for(it != prop->mapVotes.end()){
|
||||
obj.push_back(Pair((*it).second.nProposalName.c_str(), (*it).second.GetVoteString().c_str()));
|
||||
}*/
|
||||
std::map<uint256, CBudgetVote>::iterator it = prop->mapVotes.begin();
|
||||
while(it != prop->mapVotes.end())
|
||||
obj.push_back(Pair((*it).second.strProposalName.c_str(), (*it).second.GetVoteString().c_str()));
|
||||
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user