Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.44 KB | None | 0 0
  1. diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp
  2. index 3f89a57..683c9c7 100644
  3. --- a/src/masternode-budget.cpp
  4. +++ b/src/masternode-budget.cpp
  5. @@ -762,7 +762,14 @@ std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight)
  6.  
  7.  CAmount CBudgetManager::GetTotalBudget(int nHeight)
  8.  {
  9. -    if(chainActive.Tip() == NULL) return 0;
  10. +    {
  11. +        LOCK(cs_main);
  12. +        if(chainActive.Tip() == NULL) return 0;
  13. +        if(nHeight == -1) {
  14. +            int nBlockStart = chainActive.Tip()->nHeight - chainActive.Tip()->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks();
  15. +            return GetTotalBudget(nBlockStart);
  16. +        }
  17. +    }
  18.  
  19.      //get min block value and calculate from that
  20.      CAmount nSubsidy = 5 * COIN;
  21. diff --git a/src/masternode-budget.h b/src/masternode-budget.h
  22. index e75d36b..2ea24be 100644
  23. --- a/src/masternode-budget.h
  24. +++ b/src/masternode-budget.h
  25. @@ -124,7 +124,7 @@ public:
  26.      CFinalizedBudget *FindFinalizedBudget(uint256 nHash);
  27.      std::pair<std::string, std::string> GetVotes(std::string strProposalName);
  28.  
  29. -    CAmount GetTotalBudget(int nHeight);
  30. +    CAmount GetTotalBudget(int nHeight = -1);
  31.      std::vector<CBudgetProposal*> GetBudget();
  32.      std::vector<CBudgetProposal*> GetAllProposals();
  33.      std::vector<CFinalizedBudget*> GetFinalizedBudgets();
  34. diff --git a/src/rpcmasternode-budget.cpp b/src/rpcmasternode-budget.cpp
  35. index 3245349..0926583 100644
  36. --- a/src/rpcmasternode-budget.cpp
  37. +++ b/src/rpcmasternode-budget.cpp
  38. @@ -335,6 +335,7 @@ Value mnbudget(const Array& params, bool fHelp)
  39.      {
  40.          Object resultObj;
  41.          CAmount nTotalAllotted = 0;
  42. +        CAmount nTotalBudget = budget.GetTotalBudget();
  43.  
  44.          std::vector<CBudgetProposal*> winningProps = budget.GetBudget();
  45.          BOOST_FOREACH(CBudgetProposal* pbudgetProposal, winningProps)
  46. @@ -361,6 +362,7 @@ Value mnbudget(const Array& params, bool fHelp)
  47.              bObj.push_back(Pair("MonthlyPayment",  ValueFromAmount(pbudgetProposal->GetAmount())));
  48.              bObj.push_back(Pair("Alloted",  ValueFromAmount(pbudgetProposal->GetAllotted())));
  49.              bObj.push_back(Pair("TotalBudgetAlloted",  ValueFromAmount(nTotalAllotted)));
  50. +            bObj.push_back(Pair("TotalBudgetLeft",  ValueFromAmount(nTotalBudget - nTotalAllotted)));
  51.  
  52.              std::string strError = "";
  53.              bObj.push_back(Pair("IsValid",  pbudgetProposal->IsValid(strError)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement