Skip to content

Commit

Permalink
suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Oct 15, 2023
1 parent 9bc9047 commit ec65900
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/masternode/payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@
const CBlockIndex* pindex = WITH_LOCK(cs_main, return ::ChainActive()[nBlockHeight - 1]);
bool fMNRewardReallocated = llmq::utils::IsMNRewardReallocationActive(pindex);

CAmount masternodeReward = GetMasternodePayment(nBlockHeight, blockSubsidy, Params().GetConsensus().BRRHeight, fMNRewardReallocated);
CAmount masternodeReward = GetMasternodePayment(nBlockHeight, blockSubsidy + feeReward, Params().GetConsensus().BRRHeight, fMNRewardReallocated);
if (fMNRewardReallocated) {
const CAmount platformReward = MasternodePayments::PlatformShare(masternodeReward);
CAmount masternodeSubsidyReward = GetMasternodePayment(nBlockHeight, blockSubsidy, Params().GetConsensus().BRRHeight, fMNRewardReallocated);
// TODO remove this when we re-organize testnet
if (Params().NetworkIDString() == CBaseChainParams::TESTNET) {
masternodeSubsidyReward = masternodeReward;
}
const CAmount platformReward = MasternodePayments::PlatformShare(masternodeSubsidyReward);
masternodeReward -= platformReward;

assert(MoneyRange(masternodeReward));

LogPrint(BCLog::MNPAYMENTS, "CMasternodePayments::%s -- MN reward %lld reallocated to credit pool\n", __func__, platformReward);
voutMasternodePaymentsRet.emplace_back(platformReward, CScript() << OP_RETURN);
}
CAmount masternodeFeeReward = GetMasternodePayment(nBlockHeight, feeReward, Params().GetConsensus().BRRHeight, fMNRewardReallocated);
masternodeReward += masternodeFeeReward;

auto dmnPayee = deterministicMNManager->GetListForBlock(pindex).GetMNPayee(pindex);
if (!dmnPayee) {
Expand Down
5 changes: 2 additions & 3 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
// NOTE: unlike in bitcoin, we need to pass PREVIOUS block height here
bool fMNRewardReallocated = llmq::utils::IsMNRewardReallocationActive(pindexPrev);
CAmount blockSubsidy = GetBlockSubsidyInner(pindexPrev->nBits, pindexPrev->nHeight, Params().GetConsensus(), fMNRewardReallocated, /*fSuperblockPartOnly=*/ false);
CAmount feeReward = nFees;
CAmount blockReward = blockSubsidy + feeReward;
CAmount blockReward = blockSubsidy + nFees;

// Compute regular coinbase transaction.
coinbaseTx.vout[0].nValue = blockReward;
Expand Down Expand Up @@ -252,7 +251,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc

// Update coinbase transaction with additional info about masternode and governance payments,
// get some info back to pass to getblocktemplate
MasternodePayments::FillBlockPayments(spork_manager, governance_manager, coinbaseTx, nHeight, blockSubsidy, feeReward, pblocktemplate->voutMasternodePayments, pblocktemplate->voutSuperblockPayments);
MasternodePayments::FillBlockPayments(spork_manager, governance_manager, coinbaseTx, nHeight, blockSubsidy, nFees, pblocktemplate->voutMasternodePayments, pblocktemplate->voutSuperblockPayments);

pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
pblocktemplate->vTxFees[0] = -nFees;
Expand Down

0 comments on commit ec65900

Please sign in to comment.