refactor: move ExecuteBestSuperblock to CGovernanceManager

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

View File

@ -365,16 +365,16 @@ bool CSuperblockManager::IsValid(CGovernanceManager& govman, const CChain& activ
return false;
}
void CSuperblockManager::ExecuteBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, int nBlockHeight)
void CGovernanceManager::ExecuteBestSuperblock(const CDeterministicMNList& tip_mn_list, int nBlockHeight)
{
LOCK(govman.cs);
LOCK(cs);
CSuperblock_sptr pSuperblock;
if (GetBestSuperblock(govman, tip_mn_list, pSuperblock, nBlockHeight)) {
if (CSuperblockManager::GetBestSuperblock(*this, 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();
govman.ResetVotedFundingTrigger();
ResetVotedFundingTrigger();
}
}

View File

@ -33,8 +33,6 @@ public:
static bool GetBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight);
public:
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

@ -1542,7 +1542,7 @@ void CGovernanceManager::UpdatedBlockTip(const CBlockIndex* pindex, CConnman& co
CheckPostponedObjects(peerman);
CSuperblockManager::ExecuteBestSuperblock(*this, Assert(m_dmnman)->GetListAtChainTip(), pindex->nHeight);
ExecuteBestSuperblock(Assert(m_dmnman)->GetListAtChainTip(), pindex->nHeight);
}
void CGovernanceManager::RequestOrphanObjects(CConnman& connman)

View File

@ -276,6 +276,7 @@ public:
PeerMsgRet ProcessMessage(CNode& peer, CConnman& connman, PeerManager& peerman, std::string_view msg_type, CDataStream& vRecv);
private:
void ResetVotedFundingTrigger();
public:
@ -368,6 +369,8 @@ public:
std::vector<CTxOut>& voutSuperblockRet);
private:
void ExecuteBestSuperblock(const CDeterministicMNList& tip_mn_list, int nBlockHeight);
std::optional<const CSuperblock> CreateSuperblockCandidate(int nHeight) const;
std::optional<const CGovernanceObject> CreateGovernanceTrigger(const std::optional<const CSuperblock>& sb_opt, PeerManager& peerman,
const CActiveMasternodeManager& mn_activeman);