Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp
- index 3f89a57..683c9c7 100644
- --- a/src/masternode-budget.cpp
- +++ b/src/masternode-budget.cpp
- @@ -762,7 +762,14 @@ std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight)
- CAmount CBudgetManager::GetTotalBudget(int nHeight)
- {
- - if(chainActive.Tip() == NULL) return 0;
- + {
- + LOCK(cs_main);
- + if(chainActive.Tip() == NULL) return 0;
- + if(nHeight == -1) {
- + int nBlockStart = chainActive.Tip()->nHeight - chainActive.Tip()->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks();
- + return GetTotalBudget(nBlockStart);
- + }
- + }
- //get min block value and calculate from that
- CAmount nSubsidy = 5 * COIN;
- diff --git a/src/masternode-budget.h b/src/masternode-budget.h
- index e75d36b..2ea24be 100644
- --- a/src/masternode-budget.h
- +++ b/src/masternode-budget.h
- @@ -124,7 +124,7 @@ public:
- CFinalizedBudget *FindFinalizedBudget(uint256 nHash);
- std::pair<std::string, std::string> GetVotes(std::string strProposalName);
- - CAmount GetTotalBudget(int nHeight);
- + CAmount GetTotalBudget(int nHeight = -1);
- std::vector<CBudgetProposal*> GetBudget();
- std::vector<CBudgetProposal*> GetAllProposals();
- std::vector<CFinalizedBudget*> GetFinalizedBudgets();
- diff --git a/src/rpcmasternode-budget.cpp b/src/rpcmasternode-budget.cpp
- index 3245349..0926583 100644
- --- a/src/rpcmasternode-budget.cpp
- +++ b/src/rpcmasternode-budget.cpp
- @@ -335,6 +335,7 @@ Value mnbudget(const Array& params, bool fHelp)
- {
- Object resultObj;
- CAmount nTotalAllotted = 0;
- + CAmount nTotalBudget = budget.GetTotalBudget();
- std::vector<CBudgetProposal*> winningProps = budget.GetBudget();
- BOOST_FOREACH(CBudgetProposal* pbudgetProposal, winningProps)
- @@ -361,6 +362,7 @@ Value mnbudget(const Array& params, bool fHelp)
- bObj.push_back(Pair("MonthlyPayment", ValueFromAmount(pbudgetProposal->GetAmount())));
- bObj.push_back(Pair("Alloted", ValueFromAmount(pbudgetProposal->GetAllotted())));
- bObj.push_back(Pair("TotalBudgetAlloted", ValueFromAmount(nTotalAllotted)));
- + bObj.push_back(Pair("TotalBudgetLeft", ValueFromAmount(nTotalBudget - nTotalAllotted)));
- std::string strError = "";
- bObj.push_back(Pair("IsValid", pbudgetProposal->IsValid(strError)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement