Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/budget/budgetmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,12 @@ int CBudgetManager::GetHighestVoteCount(int chainHeight) const

bool CBudgetManager::GetPayeeAndAmount(int chainHeight, CScript& payeeRet, CAmount& nAmountRet) const
{
const CFinalizedBudget* pfb = GetBudgetWithHighestVoteCount(chainHeight);
if (!pfb) return false;

// Check that there are enough votes
int mnCount = mnodeman.CountEnabled(ActiveProtocol());
int nFivePercent = mnCount / 20;
if ((nFivePercent == 0 && !(Params().IsRegTestNet() && mnCount > 0) ) ||
pfb->GetVoteCount() < nFivePercent)
int nCountThreshold;
if (!IsBudgetPaymentBlock(chainHeight, nCountThreshold))
return false;

return pfb->GetPayeeAndAmount(chainHeight, payeeRet, nAmountRet);
const CFinalizedBudget* pfb = GetBudgetWithHighestVoteCount(chainHeight);
return pfb && pfb->GetPayeeAndAmount(chainHeight, payeeRet, nAmountRet) && pfb->GetVoteCount() > nCountThreshold;
}

bool CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, const int nHeight, bool fProofOfStake) const
Expand Down
7 changes: 3 additions & 4 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,9 @@ void FillBlockPayee(CMutableTransaction& txNew, const int nHeight, bool fProofOf
{
if (nHeight == 0) return;

if (!sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) || // if superblocks are not enabled
!g_budgetman.IsBudgetPaymentBlock(nHeight) || // or this is not a superblock
!g_budgetman.FillBlockPayee(txNew, nHeight, fProofOfStake) ) { // or there's no budget with enough votes
// pay a masternode
if (!sporkManager.IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) || // if superblocks are not enabled
!g_budgetman.FillBlockPayee(txNew, nHeight, fProofOfStake) ) { // or this is not a superblock,
// ... or there's no budget with enough votes, then pay a masternode
masternodePayments.FillBlockPayee(txNew, nHeight, fProofOfStake);
}
}
Expand Down