mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: move CSuperblockManager::IsValid to CGoveranceManager::IsValidSuperblock
This commit is contained in:
parent
de8969f463
commit
3641653174
@ -352,14 +352,15 @@ bool CGovernanceManager::GetSuperblockPayments(const CDeterministicMNList& tip_m
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSuperblockManager::IsValid(CGovernanceManager& govman, const CChain& active_chain, const CDeterministicMNList& tip_mn_list, const CTransaction& txNew, int nBlockHeight, CAmount blockReward)
|
||||
bool CGovernanceManager::IsValidSuperblock(const CChain& active_chain, const CDeterministicMNList& tip_mn_list,
|
||||
const CTransaction& txNew, int nBlockHeight, CAmount blockReward)
|
||||
{
|
||||
// GET BEST SUPERBLOCK, SHOULD MATCH
|
||||
LOCK(govman.cs);
|
||||
LOCK(cs);
|
||||
|
||||
CSuperblock_sptr pSuperblock;
|
||||
if (CSuperblockManager::GetBestSuperblock(govman, tip_mn_list, pSuperblock, nBlockHeight)) {
|
||||
return pSuperblock->IsValid(govman, active_chain, txNew, nBlockHeight, blockReward);
|
||||
if (CSuperblockManager::GetBestSuperblock(*this, tip_mn_list, pSuperblock, nBlockHeight)) {
|
||||
return pSuperblock->IsValid(*this, active_chain, txNew, nBlockHeight, blockReward);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -33,7 +33,6 @@ public:
|
||||
static bool GetBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight);
|
||||
|
||||
public:
|
||||
static bool IsValid(CGovernanceManager& govman, const CChain& active_chain, const CDeterministicMNList& tip_mn_list, const CTransaction& txNew, int nBlockHeight, CAmount blockReward);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -368,6 +368,9 @@ public:
|
||||
bool GetSuperblockPayments(const CDeterministicMNList& tip_mn_list, int nBlockHeight,
|
||||
std::vector<CTxOut>& voutSuperblockRet);
|
||||
|
||||
bool IsValidSuperblock(const CChain& active_chain, const CDeterministicMNList& tip_mn_list,
|
||||
const CTransaction& txNew, int nBlockHeight, CAmount blockReward);
|
||||
|
||||
private:
|
||||
void ExecuteBestSuperblock(const CDeterministicMNList& tip_mn_list, int nBlockHeight);
|
||||
|
||||
|
@ -257,7 +257,7 @@ bool CMNPaymentsProcessor::IsBlockValueValid(const CBlock& block, const int nBlo
|
||||
}
|
||||
|
||||
// this actually also checks for correct payees and not only amount
|
||||
if (!CSuperblockManager::IsValid(m_govman, m_chainman.ActiveChain(), tip_mn_list, *block.vtx[0], nBlockHeight, blockReward)) {
|
||||
if (!m_govman.IsValidSuperblock(m_chainman.ActiveChain(), tip_mn_list, *block.vtx[0], nBlockHeight, blockReward)) {
|
||||
// triggered but invalid? that's weird
|
||||
LogPrintf("CMNPaymentsProcessor::%s -- ERROR! Invalid superblock detected at height %d: %s", __func__, nBlockHeight, block.vtx[0]->ToString()); /* Continued */
|
||||
// should NOT allow invalid superblocks, when superblocks are enabled
|
||||
@ -303,7 +303,8 @@ bool CMNPaymentsProcessor::IsBlockPayeeValid(const CTransaction& txNew, const CB
|
||||
if (!check_superblock) return true;
|
||||
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
||||
if (m_govman.IsSuperblockTriggered(tip_mn_list, nBlockHeight)) {
|
||||
if (CSuperblockManager::IsValid(m_govman, m_chainman.ActiveChain(), tip_mn_list, txNew, nBlockHeight, blockSubsidy + feeReward)) {
|
||||
if (m_govman.IsValidSuperblock(m_chainman.ActiveChain(), tip_mn_list, txNew, nBlockHeight,
|
||||
blockSubsidy + feeReward)) {
|
||||
LogPrint(BCLog::GOBJECT, "CMNPaymentsProcessor::%s -- Valid superblock at height %d: %s", __func__, nBlockHeight, txNew.ToString()); /* Continued */
|
||||
// continue validation, should also pay MN
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user