mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Add spork to control deterministic MN lists activation
This commit is contained in:
parent
9e8a867149
commit
5461e92bf4
@ -11,6 +11,7 @@
|
|||||||
#include "script/standard.h"
|
#include "script/standard.h"
|
||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
#include "core_io.h"
|
#include "core_io.h"
|
||||||
|
#include "spork.h"
|
||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
@ -312,6 +313,10 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
|
|||||||
__func__, nHeight, newList.size());
|
__func__, nHeight, newList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nHeight == GetSpork15Value()) {
|
||||||
|
LogPrintf("CDeterministicMNManager::%s -- spork15 is active now. nHeight=%d\n", __func__, nHeight);
|
||||||
|
}
|
||||||
|
|
||||||
CleanupCache(nHeight);
|
CleanupCache(nHeight);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -326,6 +331,10 @@ bool CDeterministicMNManager::UndoBlock(const CBlock& block, const CBlockIndex*
|
|||||||
evoDb.Erase(std::make_pair(DB_LIST_DIFF, block.GetHash()));
|
evoDb.Erase(std::make_pair(DB_LIST_DIFF, block.GetHash()));
|
||||||
evoDb.Erase(std::make_pair(DB_LIST_SNAPSHOT, block.GetHash()));
|
evoDb.Erase(std::make_pair(DB_LIST_SNAPSHOT, block.GetHash()));
|
||||||
|
|
||||||
|
if (nHeight == GetSpork15Value()) {
|
||||||
|
LogPrintf("CDeterministicMNManager::%s -- spork15 is not active anymore. nHeight=%d\n", __func__, nHeight);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,6 +482,23 @@ bool CDeterministicMNManager::HasValidMNAtChainTip(const uint256& proTxHash)
|
|||||||
return GetListAtChainTip().IsMNValid(proTxHash);
|
return GetListAtChainTip().IsMNValid(proTxHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t CDeterministicMNManager::GetSpork15Value()
|
||||||
|
{
|
||||||
|
return sporkManager.GetSporkValue(SPORK_15_DETERMINISTIC_MNS_ENABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDeterministicMNManager::IsDeterministicMNsSporkActive(int nHeight)
|
||||||
|
{
|
||||||
|
LOCK(cs);
|
||||||
|
|
||||||
|
if (nHeight == -1) {
|
||||||
|
nHeight = tipHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t spork15Value = GetSpork15Value();
|
||||||
|
return nHeight >= spork15Value;
|
||||||
|
}
|
||||||
|
|
||||||
void CDeterministicMNManager::CleanupCache(int nHeight)
|
void CDeterministicMNManager::CleanupCache(int nHeight)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs);
|
AssertLockHeld(cs);
|
||||||
|
@ -401,7 +401,11 @@ public:
|
|||||||
bool HasValidMNAtBlock(const uint256& blockHash, const uint256& proTxHash);
|
bool HasValidMNAtBlock(const uint256& blockHash, const uint256& proTxHash);
|
||||||
bool HasValidMNAtChainTip(const uint256& proTxHash);
|
bool HasValidMNAtChainTip(const uint256& proTxHash);
|
||||||
|
|
||||||
|
bool IsDeterministicMNsSporkActive(int nHeight = -1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void UpdateSpork15Value();
|
||||||
|
int64_t GetSpork15Value();
|
||||||
void CleanupCache(int nHeight);
|
void CleanupCache(int nHeight);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ std::map<int, int64_t> mapSporkDefaults = {
|
|||||||
{SPORK_10_MASTERNODE_PAY_UPDATED_NODES, 4070908800ULL}, // OFF
|
{SPORK_10_MASTERNODE_PAY_UPDATED_NODES, 4070908800ULL}, // OFF
|
||||||
{SPORK_12_RECONSIDER_BLOCKS, 0}, // 0 BLOCKS
|
{SPORK_12_RECONSIDER_BLOCKS, 0}, // 0 BLOCKS
|
||||||
{SPORK_14_REQUIRE_SENTINEL_FLAG, 4070908800ULL}, // OFF
|
{SPORK_14_REQUIRE_SENTINEL_FLAG, 4070908800ULL}, // OFF
|
||||||
|
{SPORK_15_DETERMINISTIC_MNS_ENABLED, 4070908800ULL}, // OFF
|
||||||
};
|
};
|
||||||
|
|
||||||
void CSporkManager::Clear()
|
void CSporkManager::Clear()
|
||||||
@ -182,6 +183,7 @@ int CSporkManager::GetSporkIDByName(const std::string& strName)
|
|||||||
if (strName == "SPORK_10_MASTERNODE_PAY_UPDATED_NODES") return SPORK_10_MASTERNODE_PAY_UPDATED_NODES;
|
if (strName == "SPORK_10_MASTERNODE_PAY_UPDATED_NODES") return SPORK_10_MASTERNODE_PAY_UPDATED_NODES;
|
||||||
if (strName == "SPORK_12_RECONSIDER_BLOCKS") return SPORK_12_RECONSIDER_BLOCKS;
|
if (strName == "SPORK_12_RECONSIDER_BLOCKS") return SPORK_12_RECONSIDER_BLOCKS;
|
||||||
if (strName == "SPORK_14_REQUIRE_SENTINEL_FLAG") return SPORK_14_REQUIRE_SENTINEL_FLAG;
|
if (strName == "SPORK_14_REQUIRE_SENTINEL_FLAG") return SPORK_14_REQUIRE_SENTINEL_FLAG;
|
||||||
|
if (strName == "SPORK_15_DETERMINISTIC_MNS_ENABLED") return SPORK_15_DETERMINISTIC_MNS_ENABLED;
|
||||||
|
|
||||||
LogPrint("spork", "CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
|
LogPrint("spork", "CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
|
||||||
return -1;
|
return -1;
|
||||||
@ -199,6 +201,7 @@ std::string CSporkManager::GetSporkNameByID(int nSporkID)
|
|||||||
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: return "SPORK_10_MASTERNODE_PAY_UPDATED_NODES";
|
case SPORK_10_MASTERNODE_PAY_UPDATED_NODES: return "SPORK_10_MASTERNODE_PAY_UPDATED_NODES";
|
||||||
case SPORK_12_RECONSIDER_BLOCKS: return "SPORK_12_RECONSIDER_BLOCKS";
|
case SPORK_12_RECONSIDER_BLOCKS: return "SPORK_12_RECONSIDER_BLOCKS";
|
||||||
case SPORK_14_REQUIRE_SENTINEL_FLAG: return "SPORK_14_REQUIRE_SENTINEL_FLAG";
|
case SPORK_14_REQUIRE_SENTINEL_FLAG: return "SPORK_14_REQUIRE_SENTINEL_FLAG";
|
||||||
|
case SPORK_15_DETERMINISTIC_MNS_ENABLED: return "SPORK_15_DETERMINISTIC_MNS_ENABLED";
|
||||||
default:
|
default:
|
||||||
LogPrint("spork", "CSporkManager::GetSporkNameByID -- Unknown Spork ID %d\n", nSporkID);
|
LogPrint("spork", "CSporkManager::GetSporkNameByID -- Unknown Spork ID %d\n", nSporkID);
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
|
@ -26,9 +26,10 @@ static const int SPORK_9_SUPERBLOCKS_ENABLED = 10008;
|
|||||||
static const int SPORK_10_MASTERNODE_PAY_UPDATED_NODES = 10009;
|
static const int SPORK_10_MASTERNODE_PAY_UPDATED_NODES = 10009;
|
||||||
static const int SPORK_12_RECONSIDER_BLOCKS = 10011;
|
static const int SPORK_12_RECONSIDER_BLOCKS = 10011;
|
||||||
static const int SPORK_14_REQUIRE_SENTINEL_FLAG = 10013;
|
static const int SPORK_14_REQUIRE_SENTINEL_FLAG = 10013;
|
||||||
|
static const int SPORK_15_DETERMINISTIC_MNS_ENABLED = 10014;
|
||||||
|
|
||||||
static const int SPORK_START = SPORK_2_INSTANTSEND_ENABLED;
|
static const int SPORK_START = SPORK_2_INSTANTSEND_ENABLED;
|
||||||
static const int SPORK_END = SPORK_14_REQUIRE_SENTINEL_FLAG;
|
static const int SPORK_END = SPORK_15_DETERMINISTIC_MNS_ENABLED;
|
||||||
|
|
||||||
extern std::map<int, int64_t> mapSporkDefaults;
|
extern std::map<int, int64_t> mapSporkDefaults;
|
||||||
extern CSporkManager sporkManager;
|
extern CSporkManager sporkManager;
|
||||||
|
Loading…
Reference in New Issue
Block a user