mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: move GetBestSuperblock to CGovernanceManager
This commit is contained in:
parent
3641653174
commit
b240d08e09
@ -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)) {
|
if (!CSuperblock::IsValidBlockHeight(nBlockHeight)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssertLockHeld(govman.cs);
|
AssertLockHeld(cs);
|
||||||
std::vector<CSuperblock_sptr> vecTriggers = govman.GetActiveTriggers();
|
std::vector<CSuperblock_sptr> vecTriggers = GetActiveTriggers();
|
||||||
int nYesCount = 0;
|
int nYesCount = 0;
|
||||||
|
|
||||||
for (const auto& pSuperblock : vecTriggers) {
|
for (const auto& pSuperblock : vecTriggers) {
|
||||||
@ -287,7 +288,7 @@ bool CSuperblockManager::GetBestSuperblock(CGovernanceManager& govman, const CDe
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CGovernanceObject* pObj = pSuperblock->GetGovernanceObject(govman);
|
const CGovernanceObject* pObj = pSuperblock->GetGovernanceObject(*this);
|
||||||
|
|
||||||
if (!pObj) {
|
if (!pObj) {
|
||||||
continue;
|
continue;
|
||||||
@ -313,7 +314,7 @@ bool CGovernanceManager::GetSuperblockPayments(const CDeterministicMNList& tip_m
|
|||||||
// GET THE BEST SUPERBLOCK FOR THIS BLOCK HEIGHT
|
// GET THE BEST SUPERBLOCK FOR THIS BLOCK HEIGHT
|
||||||
|
|
||||||
CSuperblock_sptr pSuperblock;
|
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);
|
LogPrint(BCLog::GOBJECT, "GetSuperblockPayments -- Can't find superblock for height %d\n", nBlockHeight);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -359,7 +360,7 @@ bool CGovernanceManager::IsValidSuperblock(const CChain& active_chain, const CDe
|
|||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
CSuperblock_sptr pSuperblock;
|
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);
|
return pSuperblock->IsValid(*this, active_chain, txNew, nBlockHeight, blockReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +372,7 @@ void CGovernanceManager::ExecuteBestSuperblock(const CDeterministicMNList& tip_m
|
|||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
CSuperblock_sptr pSuperblock;
|
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,
|
// 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.
|
// tip wouldn't be updated if anything was wrong. Mark this trigger as executed.
|
||||||
pSuperblock->SetExecuted();
|
pSuperblock->SetExecuted();
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
class CChain;
|
class CChain;
|
||||||
class CGovernanceManager;
|
class CGovernanceManager;
|
||||||
class CSuperblock;
|
class CSuperblock;
|
||||||
class CSuperblockManager;
|
|
||||||
class CTxOut;
|
class CTxOut;
|
||||||
class CTransaction;
|
class CTransaction;
|
||||||
|
|
||||||
@ -21,20 +20,6 @@ using CSuperblock_sptr = std::shared_ptr<CSuperblock>;
|
|||||||
|
|
||||||
CAmount ParsePaymentAmount(const std::string& strAmount);
|
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
|
* Governance Object Payment
|
||||||
*
|
*
|
||||||
|
@ -373,6 +373,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void ExecuteBestSuperblock(const CDeterministicMNList& tip_mn_list, int nBlockHeight);
|
void ExecuteBestSuperblock(const CDeterministicMNList& tip_mn_list, int nBlockHeight);
|
||||||
|
bool GetBestSuperblock(const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight);
|
||||||
|
|
||||||
std::optional<const CSuperblock> CreateSuperblockCandidate(int nHeight) const;
|
std::optional<const CSuperblock> CreateSuperblockCandidate(int nHeight) const;
|
||||||
std::optional<const CGovernanceObject> CreateGovernanceTrigger(const std::optional<const CSuperblock>& sb_opt, PeerManager& peerman,
|
std::optional<const CGovernanceObject> CreateGovernanceTrigger(const std::optional<const CSuperblock>& sb_opt, PeerManager& peerman,
|
||||||
|
Loading…
Reference in New Issue
Block a user