mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
refactor: move out helper IsDIP3Enforced from deterministicmns
This commit is contained in:
parent
5a84eb0f0a
commit
a79aa56d9b
@ -52,4 +52,10 @@ inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::Deploy
|
||||
return params.vDeployments[dep].nTimeout != 0;
|
||||
}
|
||||
|
||||
/** this function is convenient helper for DIP0003 because 'active' and 'enforced' are different statuses for DIP0003 */
|
||||
constexpr bool DeploymentDIP0003Enforced(const int nHeight, const Consensus::Params& params)
|
||||
{
|
||||
return nHeight >= params.DIP0003EnforcementHeight;
|
||||
}
|
||||
|
||||
#endif // BITCOIN_DEPLOYMENTSTATUS_H
|
||||
|
@ -1118,11 +1118,6 @@ bool CDeterministicMNManager::IsProTxWithCollateral(const CTransactionRef& tx, u
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDeterministicMNManager::IsDIP3Enforced(int nHeight)
|
||||
{
|
||||
return nHeight >= Params().GetConsensus().DIP0003EnforcementHeight;
|
||||
}
|
||||
|
||||
void CDeterministicMNManager::CleanupCache(int nHeight)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
@ -1612,7 +1607,7 @@ bool CheckProRegTx(const CTransaction& tx, gsl::not_null<const CBlockIndex*> pin
|
||||
}
|
||||
}
|
||||
|
||||
if (!deterministicMNManager->IsDIP3Enforced(pindexPrev->nHeight)) {
|
||||
if (!DeploymentDIP0003Enforced(pindexPrev->nHeight, Params().GetConsensus())) {
|
||||
if (ptx.keyIDOwner != ptx.keyIDVoting) {
|
||||
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-key-not-same");
|
||||
}
|
||||
@ -1749,7 +1744,7 @@ bool CheckProUpRegTx(const CTransaction& tx, gsl::not_null<const CBlockIndex*> p
|
||||
}
|
||||
}
|
||||
|
||||
if (!deterministicMNManager->IsDIP3Enforced(pindexPrev->nHeight)) {
|
||||
if (!DeploymentDIP0003Enforced(pindexPrev->nHeight, Params().GetConsensus())) {
|
||||
if (dmn->pdmnState->keyIDOwner != ptx.keyIDVoting) {
|
||||
return state.Invalid(TxValidationResult::TX_BAD_SPECIAL, "bad-protx-key-not-same");
|
||||
}
|
||||
|
@ -622,8 +622,6 @@ public:
|
||||
// Test if given TX is a ProRegTx which also contains the collateral at index n
|
||||
static bool IsProTxWithCollateral(const CTransactionRef& tx, uint32_t n);
|
||||
|
||||
bool IsDIP3Enforced(int nHeight);
|
||||
|
||||
bool MigrateDBIfNeeded();
|
||||
bool MigrateDBIfNeeded2();
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <deploymentstatus.h>
|
||||
#include <evo/deterministicmns.h>
|
||||
#include <flat-database.h>
|
||||
#include <governance/classes.h>
|
||||
@ -1461,7 +1462,7 @@ void CGovernanceManager::UpdatedBlockTip(const CBlockIndex* pindex, CConnman& co
|
||||
nCachedBlockHeight = pindex->nHeight;
|
||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight: %d\n", nCachedBlockHeight);
|
||||
|
||||
if (deterministicMNManager->IsDIP3Enforced(pindex->nHeight)) {
|
||||
if (DeploymentDIP0003Enforced(pindex->nHeight, Params().GetConsensus())) {
|
||||
RemoveInvalidVotes();
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <evo/deterministicmns.h>
|
||||
|
||||
#include <deploymentstatus.h>
|
||||
#include <masternode/node.h>
|
||||
#include <chainparams.h>
|
||||
#include <net_processing.h>
|
||||
@ -168,7 +169,7 @@ bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
|
||||
{
|
||||
curSession = std::make_unique<CDKGSession>(params, blsWorker, dkgManager, dkgDebugManager, connman);
|
||||
|
||||
if (!deterministicMNManager->IsDIP3Enforced(pQuorumBaseBlockIndex->nHeight)) {
|
||||
if (!DeploymentDIP0003Enforced(pQuorumBaseBlockIndex->nHeight, Params().GetConsensus())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include <llmq/quorums.h>
|
||||
#include <llmq/utils.h>
|
||||
|
||||
#include <evo/deterministicmns.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <dbwrapper.h>
|
||||
#include <deploymentstatus.h>
|
||||
#include <evo/deterministicmns.h>
|
||||
#include <net_processing.h>
|
||||
#include <spork.h>
|
||||
#include <util/irange.h>
|
||||
@ -162,7 +162,7 @@ void CDKGSessionManager::UpdatedBlockTip(const CBlockIndex* pindexNew, bool fIni
|
||||
|
||||
if (fInitialDownload)
|
||||
return;
|
||||
if (!deterministicMNManager->IsDIP3Enforced(pindexNew->nHeight))
|
||||
if (!DeploymentDIP0003Enforced(pindexNew->nHeight, Params().GetConsensus()))
|
||||
return;
|
||||
if (!IsQuorumDKGEnabled(spork_manager))
|
||||
return;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <evo/deterministicmns.h>
|
||||
|
||||
#include <chainparams.h>
|
||||
#include <deploymentstatus.h>
|
||||
#include <net.h>
|
||||
#include <netbase.h>
|
||||
#include <protocol.h>
|
||||
@ -68,7 +69,7 @@ void CActiveMasternodeManager::Init(const CBlockIndex* pindex)
|
||||
|
||||
if (!fMasternodeMode) return;
|
||||
|
||||
if (!deterministicMNManager->IsDIP3Enforced(pindex->nHeight)) return;
|
||||
if (!DeploymentDIP0003Enforced(pindex->nHeight, Params().GetConsensus())) return;
|
||||
|
||||
// Check that our local network configuration is correct
|
||||
if (!fListen && Params().RequireRoutableExternalIP()) {
|
||||
@ -141,7 +142,7 @@ void CActiveMasternodeManager::UpdatedBlockTip(const CBlockIndex* pindexNew, con
|
||||
|
||||
if (!fMasternodeMode) return;
|
||||
|
||||
if (!deterministicMNManager->IsDIP3Enforced(pindexNew->nHeight)) return;
|
||||
if (!DeploymentDIP0003Enforced(pindexNew->nHeight, Params().GetConsensus())) return;
|
||||
|
||||
if (state == MASTERNODE_READY) {
|
||||
auto oldMNList = deterministicMNManager->GetListForBlock(pindexNew->pprev);
|
||||
|
@ -98,7 +98,7 @@
|
||||
[[nodiscard]] static bool IsTransactionValid(const CTransaction& txNew, const CBlockIndex* const pindexPrev, const CAmount blockSubsidy, const CAmount feeReward)
|
||||
{
|
||||
const int nBlockHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1;
|
||||
if (!deterministicMNManager->IsDIP3Enforced(nBlockHeight)) {
|
||||
if (!DeploymentDIP0003Enforced(nBlockHeight, Params().GetConsensus())) {
|
||||
// can't verify historical blocks here
|
||||
return true;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ BOOST_FIXTURE_TEST_CASE(block_reward_reallocation, TestChainBRRBeforeActivationS
|
||||
|
||||
CScript coinbasePubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
|
||||
|
||||
BOOST_ASSERT(deterministicMNManager->IsDIP3Enforced(WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Height())));
|
||||
BOOST_ASSERT(DeploymentDIP0003Enforced(WITH_LOCK(cs_main, return m_node.chainman->ActiveChain().Height()), consensus_params));
|
||||
|
||||
// Register one MN
|
||||
CKey ownerKey;
|
||||
|
Loading…
Reference in New Issue
Block a user