Merge pull request #602 from UdjinM6/remainingoffby1

fix: GetRemainingPaymentCount was off by 1
This commit is contained in:
evan82 2015-09-07 12:03:55 -07:00
commit 818303dbbd

View File

@ -1487,10 +1487,9 @@ int CBudgetProposal::GetTotalPaymentCount()
int CBudgetProposal::GetRemainingPaymentCount()
{
// If this budget starts in the future, this value will be wrong
int nPayments = (GetBlockEndCycle() - GetBlockCurrentCycle()) / GetBudgetPaymentCycleBlocks();
int nTotal = (GetBlockEndCycle() - GetBlockStartCycle()) / GetBudgetPaymentCycleBlocks();
int nPayments = (GetBlockEndCycle() - GetBlockCurrentCycle()) / GetBudgetPaymentCycleBlocks() - 1;
// Take the lowest value
return (nPayments <= nTotal ? nPayments : nTotal);
return std::min(nPayments, GetTotalPaymentCount());
}
CBudgetProposalBroadcast::CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn)