Added mnbudget projection and changed "show"

- Show now shows every proposal that is known, which seems to be the general expected behavior of the users
- Added "projection" for showing what will end up in the budget if it was finalized currently
This commit is contained in:
Evan Duffield 2015-07-03 10:54:10 -07:00
parent 151cb174f2
commit 6becaf0462
5 changed files with 55 additions and 5 deletions

View File

@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 12) define(_CLIENT_VERSION_MINOR, 12)
define(_CLIENT_VERSION_REVISION, 0) define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 7) define(_CLIENT_VERSION_BUILD, 8)
define(_CLIENT_VERSION_IS_RELEASE, true) define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2015) define(_COPYRIGHT_YEAR, 2015)
AC_INIT([Dash Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@dashpay.io],[dash]) AC_INIT([Dash Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@dashpay.io],[dash])

View File

@ -17,7 +17,7 @@
#define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 12 #define CLIENT_VERSION_MINOR 12
#define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 7 #define CLIENT_VERSION_BUILD 8
//! Set to true for release, false for prerelease or test build //! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true #define CLIENT_VERSION_IS_RELEASE true

View File

@ -458,6 +458,22 @@ bool CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHei
return false; return false;
} }
std::vector<CBudgetProposal*> CBudgetManager::GetAllProposals()
{
std::vector<CBudgetProposal*> ret;
std::map<uint256, CBudgetProposal>::iterator it2 = mapProposals.begin();
while(it2 != mapProposals.end())
{
CBudgetProposal* prop = &((*it2).second);
ret.push_back(prop);
it2++;
}
return ret;
}
//Need to review this function //Need to review this function
std::vector<CBudgetProposal*> CBudgetManager::GetBudget() std::vector<CBudgetProposal*> CBudgetManager::GetBudget()
{ {
@ -496,7 +512,6 @@ std::vector<CBudgetProposal*> CBudgetManager::GetBudget()
//prop start/end should be inside this period //prop start/end should be inside this period
if(prop->nBlockStart <= nBlockStart && prop->nBlockEnd >= nBlockEnd) if(prop->nBlockStart <= nBlockStart && prop->nBlockEnd >= nBlockEnd)
{ {
if(nTotalBudget == nBudgetAllocated){ if(nTotalBudget == nBudgetAllocated){
prop->SetAllotted(0); prop->SetAllotted(0);
} else if(prop->GetAmount() + nBudgetAllocated <= nTotalBudget) { } else if(prop->GetAmount() + nBudgetAllocated <= nTotalBudget) {

View File

@ -103,6 +103,7 @@ public:
int64_t GetTotalBudget(int nHeight); int64_t GetTotalBudget(int nHeight);
std::vector<CBudgetProposal*> GetBudget(); std::vector<CBudgetProposal*> GetBudget();
std::vector<CBudgetProposal*> GetAllProposals();
std::vector<CFinalizedBudget*> GetFinalizedBudgets(); std::vector<CFinalizedBudget*> GetFinalizedBudgets();
bool IsBudgetPaymentBlock(int nBlockHeight); bool IsBudgetPaymentBlock(int nBlockHeight);
void AddProposal(CBudgetProposal& prop); void AddProposal(CBudgetProposal& prop);

View File

@ -25,7 +25,7 @@ Value mnbudget(const Array& params, bool fHelp)
strCommand = params[0].get_str(); strCommand = params[0].get_str();
if (fHelp || if (fHelp ||
(strCommand != "vote-many" && strCommand != "vote" && strCommand != "getvotes" && strCommand != "getinfo" && strCommand != "show")) (strCommand != "vote-many" && strCommand != "vote" && strCommand != "getvotes" && strCommand != "getinfo" && strCommand != "show" && strCommand != "projection"))
throw runtime_error( throw runtime_error(
"mnbudget \"command\"... ( \"passphrase\" )\n" "mnbudget \"command\"... ( \"passphrase\" )\n"
"Vote or show current budgets\n" "Vote or show current budgets\n"
@ -36,6 +36,7 @@ Value mnbudget(const Array& params, bool fHelp)
" getvotes - Show current masternode budgets\n" " getvotes - Show current masternode budgets\n"
" getinfo - Show current masternode budgets\n" " getinfo - Show current masternode budgets\n"
" show - Show all budgets\n" " show - Show all budgets\n"
" projection - Show the projection of which proposals will be paid the next cycle\n"
); );
if(strCommand == "vote-many") if(strCommand == "vote-many")
@ -227,7 +228,7 @@ Value mnbudget(const Array& params, bool fHelp)
} }
if(strCommand == "show") if(strCommand == "projection")
{ {
Object resultObj; Object resultObj;
int64_t nTotalAllotted = 0; int64_t nTotalAllotted = 0;
@ -261,6 +262,39 @@ Value mnbudget(const Array& params, bool fHelp)
return resultObj; return resultObj;
} }
if(strCommand == "show")
{
Object resultObj;
int64_t nTotalAllotted = 0;
std::vector<CBudgetProposal*> winningProps = budget.GetAllProposals();
BOOST_FOREACH(CBudgetProposal* prop, winningProps)
{
nTotalAllotted += prop->GetAllotted();
CTxDestination address1;
ExtractDestination(prop->GetPayee(), address1);
CBitcoinAddress address2(address1);
Object bObj;
bObj.push_back(Pair("URL", prop->GetURL()));
bObj.push_back(Pair("Hash", prop->GetHash().ToString().c_str()));
bObj.push_back(Pair("BlockStart", (int64_t)prop->GetBlockStart()));
bObj.push_back(Pair("BlockEnd", (int64_t)prop->GetBlockEnd()));
bObj.push_back(Pair("TotalPaymentCount", (int64_t)prop->GetTotalPaymentCount()));
bObj.push_back(Pair("RemainingPaymentCount", (int64_t)prop->GetRemainingPaymentCount()));
bObj.push_back(Pair("PaymentAddress", address2.ToString().c_str()));
bObj.push_back(Pair("Ratio", prop->GetRatio()));
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("Amount", (int64_t)prop->GetAmount()));
resultObj.push_back(Pair(prop->GetName().c_str(), bObj));
}
return resultObj;
}
if(strCommand == "getinfo") if(strCommand == "getinfo")
{ {
if (params.size() != 2) if (params.size() != 2)