diff --git a/src/governance/classes.cpp b/src/governance/classes.cpp index 9e0e0ba7bc..4b12212940 100644 --- a/src/governance/classes.cpp +++ b/src/governance/classes.cpp @@ -272,14 +272,15 @@ bool CGovernanceManager::IsSuperblockTriggered(const CDeterministicMNList& tip_m } -bool CSuperblockManager::GetBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight) +bool CGovernanceManager::GetBestSuperblock(const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, + int nBlockHeight) const { if (!CSuperblock::IsValidBlockHeight(nBlockHeight)) { return false; } - AssertLockHeld(govman.cs); - std::vector vecTriggers = govman.GetActiveTriggers(); + AssertLockHeld(cs); + std::vector vecTriggers = GetActiveTriggers(); int nYesCount = 0; for (const auto& pSuperblock : vecTriggers) { @@ -287,7 +288,7 @@ bool CSuperblockManager::GetBestSuperblock(CGovernanceManager& govman, const CDe continue; } - const CGovernanceObject* pObj = pSuperblock->GetGovernanceObject(govman); + const CGovernanceObject* pObj = pSuperblock->GetGovernanceObject(*this); if (!pObj) { continue; @@ -313,7 +314,7 @@ bool CGovernanceManager::GetSuperblockPayments(const CDeterministicMNList& tip_m // GET THE BEST SUPERBLOCK FOR THIS BLOCK HEIGHT CSuperblock_sptr pSuperblock; - if (!CSuperblockManager::GetBestSuperblock(*this, tip_mn_list, pSuperblock, nBlockHeight)) { + if (!GetBestSuperblock(tip_mn_list, pSuperblock, nBlockHeight)) { LogPrint(BCLog::GOBJECT, "GetSuperblockPayments -- Can't find superblock for height %d\n", nBlockHeight); return false; } @@ -359,7 +360,7 @@ bool CGovernanceManager::IsValidSuperblock(const CChain& active_chain, const CDe LOCK(cs); CSuperblock_sptr pSuperblock; - if (CSuperblockManager::GetBestSuperblock(*this, tip_mn_list, pSuperblock, nBlockHeight)) { + if (GetBestSuperblock(tip_mn_list, pSuperblock, nBlockHeight)) { return pSuperblock->IsValid(*this, active_chain, txNew, nBlockHeight, blockReward); } @@ -371,7 +372,7 @@ void CGovernanceManager::ExecuteBestSuperblock(const CDeterministicMNList& tip_m LOCK(cs); CSuperblock_sptr pSuperblock; - if (CSuperblockManager::GetBestSuperblock(*this, tip_mn_list, pSuperblock, nBlockHeight)) { + if (GetBestSuperblock(tip_mn_list, pSuperblock, nBlockHeight)) { // All checks are done in CSuperblock::IsValid via IsBlockValueValid and IsBlockPayeeValid, // tip wouldn't be updated if anything was wrong. Mark this trigger as executed. pSuperblock->SetExecuted(); diff --git a/src/governance/classes.h b/src/governance/classes.h index ce19bdbe5d..1d5e610c5d 100644 --- a/src/governance/classes.h +++ b/src/governance/classes.h @@ -13,7 +13,6 @@ class CChain; class CGovernanceManager; class CSuperblock; -class CSuperblockManager; class CTxOut; class CTransaction; @@ -21,20 +20,6 @@ using CSuperblock_sptr = std::shared_ptr; CAmount ParsePaymentAmount(const std::string& strAmount); -/** -* Superblock Manager -* -* Class for querying superblock information -*/ - -class CSuperblockManager -{ -public: - static bool GetBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight); - -public: -}; - /** * Governance Object Payment * diff --git a/src/governance/governance.h b/src/governance/governance.h index 864d9b423d..b6e64b979b 100644 --- a/src/governance/governance.h +++ b/src/governance/governance.h @@ -373,6 +373,7 @@ public: private: void ExecuteBestSuperblock(const CDeterministicMNList& tip_mn_list, int nBlockHeight); + bool GetBestSuperblock(const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight); std::optional CreateSuperblockCandidate(int nHeight) const; std::optional CreateGovernanceTrigger(const std::optional& sb_opt, PeerManager& peerman,