mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
refactor: move GetSuperblockPayments to CGovernanceManager
This commit is contained in:
parent
7a470c441e
commit
107d5b4941
@ -305,21 +305,16 @@ bool CSuperblockManager::GetBestSuperblock(CGovernanceManager& govman, const CDe
|
|||||||
return nYesCount > 0;
|
return nYesCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
bool CGovernanceManager::GetSuperblockPayments(const CDeterministicMNList& tip_mn_list, int nBlockHeight,
|
||||||
* Get Superblock Payments
|
std::vector<CTxOut>& voutSuperblockRet)
|
||||||
*
|
|
||||||
* - Returns payments for superblock
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool CSuperblockManager::GetSuperblockPayments(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, int nBlockHeight, std::vector<CTxOut>& voutSuperblockRet)
|
|
||||||
{
|
{
|
||||||
LOCK(govman.cs);
|
LOCK(cs);
|
||||||
|
|
||||||
// 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(govman, tip_mn_list, pSuperblock, nBlockHeight)) {
|
if (!CSuperblockManager::GetBestSuperblock(*this, tip_mn_list, pSuperblock, nBlockHeight)) {
|
||||||
LogPrint(BCLog::GOBJECT, "CSuperblockManager::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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,10 +342,10 @@ bool CSuperblockManager::GetSuperblockPayments(CGovernanceManager& govman, const
|
|||||||
CTxDestination dest;
|
CTxDestination dest;
|
||||||
ExtractDestination(payment.script, dest);
|
ExtractDestination(payment.script, dest);
|
||||||
|
|
||||||
LogPrint(BCLog::GOBJECT, "CSuperblockManager::GetSuperblockPayments -- NEW Superblock: output %d (addr %s, amount %d.%08d)\n",
|
LogPrint(BCLog::GOBJECT, "GetSuperblockPayments -- NEW Superblock: output %d (addr %s, amount %d.%08d)\n",
|
||||||
i, EncodeDestination(dest), payment.nAmount / COIN, payment.nAmount % COIN);
|
i, EncodeDestination(dest), payment.nAmount / COIN, payment.nAmount % COIN);
|
||||||
} else {
|
} else {
|
||||||
LogPrint(BCLog::GOBJECT, "CSuperblockManager::GetSuperblockPayments -- Payment not found\n");
|
LogPrint(BCLog::GOBJECT, "GetSuperblockPayments -- Payment not found\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +29,10 @@ CAmount ParsePaymentAmount(const std::string& strAmount);
|
|||||||
|
|
||||||
class CSuperblockManager
|
class CSuperblockManager
|
||||||
{
|
{
|
||||||
private:
|
public:
|
||||||
static bool GetBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight);
|
static bool GetBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, CSuperblock_sptr& pSuperblockRet, int nBlockHeight);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool GetSuperblockPayments(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, int nBlockHeight, std::vector<CTxOut>& voutSuperblockRet);
|
|
||||||
static void ExecuteBestSuperblock(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, int nBlockHeight);
|
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);
|
static bool IsValid(CGovernanceManager& govman, const CChain& active_chain, const CDeterministicMNList& tip_mn_list, const CTransaction& txNew, int nBlockHeight, CAmount blockReward);
|
||||||
|
@ -357,9 +357,15 @@ public:
|
|||||||
*
|
*
|
||||||
* - Does this block have a non-executed and activated trigger?
|
* - Does this block have a non-executed and activated trigger?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool IsSuperblockTriggered(const CDeterministicMNList& tip_mn_list, int nBlockHeight);
|
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<CTxOut>& voutSuperblockRet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::optional<const CSuperblock> CreateSuperblockCandidate(int nHeight) const;
|
std::optional<const CSuperblock> CreateSuperblockCandidate(int nHeight) const;
|
||||||
|
@ -332,7 +332,7 @@ void CMNPaymentsProcessor::FillBlockPayments(CMutableTransaction& txNew, const C
|
|||||||
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
||||||
if (AreSuperblocksEnabled(m_sporkman) && m_govman.IsSuperblockTriggered(tip_mn_list, nBlockHeight)) {
|
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);
|
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)) {
|
if (!GetMasternodeTxOuts(pindexPrev, blockSubsidy, feeReward, voutMasternodePaymentsRet)) {
|
||||||
|
@ -255,7 +255,7 @@ static std::string GetRequiredPaymentsString(CGovernanceManager& govman, const C
|
|||||||
}
|
}
|
||||||
if (govman.IsSuperblockTriggered(tip_mn_list, nBlockHeight)) {
|
if (govman.IsSuperblockTriggered(tip_mn_list, nBlockHeight)) {
|
||||||
std::vector<CTxOut> voutSuperblock;
|
std::vector<CTxOut> voutSuperblock;
|
||||||
if (!CSuperblockManager::GetSuperblockPayments(govman, tip_mn_list, nBlockHeight, voutSuperblock)) {
|
if (!govman.GetSuperblockPayments(tip_mn_list, nBlockHeight, voutSuperblock)) {
|
||||||
return strPayments + ", error";
|
return strPayments + ", error";
|
||||||
}
|
}
|
||||||
std::string strSBPayees = "Unknown";
|
std::string strSBPayees = "Unknown";
|
||||||
|
Loading…
Reference in New Issue
Block a user