refactor: move GetSuperblockPayments to CGovernanceManager

This commit is contained in:
Konstantin Akimov 2024-10-06 20:30:32 +07:00
parent 7a470c441e
commit 107d5b4941
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
5 changed files with 18 additions and 18 deletions

View File

@ -305,21 +305,16 @@ bool CSuperblockManager::GetBestSuperblock(CGovernanceManager& govman, const CDe
return nYesCount > 0;
}
/**
* Get Superblock Payments
*
* - Returns payments for superblock
*/
bool CSuperblockManager::GetSuperblockPayments(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, int nBlockHeight, std::vector<CTxOut>& voutSuperblockRet)
bool CGovernanceManager::GetSuperblockPayments(const CDeterministicMNList& tip_mn_list, int nBlockHeight,
std::vector<CTxOut>& voutSuperblockRet)
{
LOCK(govman.cs);
LOCK(cs);
// GET THE BEST SUPERBLOCK FOR THIS BLOCK HEIGHT
CSuperblock_sptr pSuperblock;
if (!CSuperblockManager::GetBestSuperblock(govman, tip_mn_list, pSuperblock, nBlockHeight)) {
LogPrint(BCLog::GOBJECT, "CSuperblockManager::GetSuperblockPayments -- Can't find superblock for height %d\n", nBlockHeight);
if (!CSuperblockManager::GetBestSuperblock(*this, tip_mn_list, pSuperblock, nBlockHeight)) {
LogPrint(BCLog::GOBJECT, "GetSuperblockPayments -- Can't find superblock for height %d\n", nBlockHeight);
return false;
}
@ -347,10 +342,10 @@ bool CSuperblockManager::GetSuperblockPayments(CGovernanceManager& govman, const
CTxDestination dest;
ExtractDestination(payment.script, dest);
LogPrint(BCLog::GOBJECT, "CSuperblockManager::GetSuperblockPayments -- NEW Superblock: output %d (addr %s, amount %d.%08d)\n",
i, EncodeDestination(dest), payment.nAmount / COIN, payment.nAmount % COIN);
LogPrint(BCLog::GOBJECT, "GetSuperblockPayments -- NEW Superblock: output %d (addr %s, amount %d.%08d)\n",
i, EncodeDestination(dest), payment.nAmount / COIN, payment.nAmount % COIN);
} else {
LogPrint(BCLog::GOBJECT, "CSuperblockManager::GetSuperblockPayments -- Payment not found\n");
LogPrint(BCLog::GOBJECT, "GetSuperblockPayments -- Payment not found\n");
}
}

View File

@ -29,11 +29,10 @@ CAmount ParsePaymentAmount(const std::string& strAmount);
class CSuperblockManager
{
private:
public:
static bool GetBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight);
public:
static bool GetSuperblockPayments(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, int nBlockHeight, std::vector<CTxOut>& voutSuperblockRet);
static void ExecuteBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, int nBlockHeight);
static bool IsValid(CGovernanceManager& govman, const CChain& active_chain, const CDeterministicMNList& tip_mn_list, const CTransaction& txNew, int nBlockHeight, CAmount blockReward);

View File

@ -357,9 +357,15 @@ public:
*
* - Does this block have a non-executed and activated trigger?
*/
bool IsSuperblockTriggered(const CDeterministicMNList& tip_mn_list, int nBlockHeight);
/**
* Get Superblock Payments
*
* - Returns payments for superblock
*/
bool GetSuperblockPayments(const CDeterministicMNList& tip_mn_list, int nBlockHeight,
std::vector<CTxOut>& voutSuperblockRet);
private:
std::optional<const CSuperblock> CreateSuperblockCandidate(int nHeight) const;

View File

@ -332,7 +332,7 @@ void CMNPaymentsProcessor::FillBlockPayments(CMutableTransaction& txNew, const C
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
if (AreSuperblocksEnabled(m_sporkman) && m_govman.IsSuperblockTriggered(tip_mn_list, nBlockHeight)) {
LogPrint(BCLog::GOBJECT, "CMNPaymentsProcessor::%s -- Triggered superblock creation at height %d\n", __func__, nBlockHeight);
CSuperblockManager::GetSuperblockPayments(m_govman, tip_mn_list, nBlockHeight, voutSuperblockPaymentsRet);
m_govman.GetSuperblockPayments(tip_mn_list, nBlockHeight, voutSuperblockPaymentsRet);
}
if (!GetMasternodeTxOuts(pindexPrev, blockSubsidy, feeReward, voutMasternodePaymentsRet)) {

View File

@ -255,7 +255,7 @@ static std::string GetRequiredPaymentsString(CGovernanceManager& govman, const C
}
if (govman.IsSuperblockTriggered(tip_mn_list, nBlockHeight)) {
std::vector<CTxOut> voutSuperblock;
if (!CSuperblockManager::GetSuperblockPayments(govman, tip_mn_list, nBlockHeight, voutSuperblock)) {
if (!govman.GetSuperblockPayments(tip_mn_list, nBlockHeight, voutSuperblock)) {
return strPayments + ", error";
}
std::string strSBPayees = "Unknown";