diff --git a/src/governance/classes.cpp b/src/governance/classes.cpp index fec30027ea..98850bf97a 100644 --- a/src/governance/classes.cpp +++ b/src/governance/classes.cpp @@ -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& voutSuperblockRet) +bool CGovernanceManager::GetSuperblockPayments(const CDeterministicMNList& tip_mn_list, int nBlockHeight, + std::vector& 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"); } } diff --git a/src/governance/classes.h b/src/governance/classes.h index 759325ed0f..ee73a25a0d 100644 --- a/src/governance/classes.h +++ b/src/governance/classes.h @@ -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& 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); diff --git a/src/governance/governance.h b/src/governance/governance.h index 3166c39c4a..64d0938b0c 100644 --- a/src/governance/governance.h +++ b/src/governance/governance.h @@ -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& voutSuperblockRet); private: std::optional CreateSuperblockCandidate(int nHeight) const; diff --git a/src/masternode/payments.cpp b/src/masternode/payments.cpp index 853b587024..b7d264a7bb 100644 --- a/src/masternode/payments.cpp +++ b/src/masternode/payments.cpp @@ -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)) { diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 8f86534ad3..271c15451d 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -255,7 +255,7 @@ static std::string GetRequiredPaymentsString(CGovernanceManager& govman, const C } if (govman.IsSuperblockTriggered(tip_mn_list, nBlockHeight)) { std::vector 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";