Add SPORK_19_CHAINLOCKS_ENABLED

This commit is contained in:
Alexander Block 2019-01-23 17:40:37 +01:00
parent 29532ba196
commit 135829dc49
3 changed files with 24 additions and 1 deletions

View File

@ -10,6 +10,7 @@
#include "chain.h"
#include "net_processing.h"
#include "scheduler.h"
#include "spork.h"
#include "validation.h"
namespace llmq
@ -56,6 +57,10 @@ bool CChainLocksHandler::GetChainLockByHash(const uint256& hash, llmq::CChainLoc
void CChainLocksHandler::ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman)
{
if (!sporkManager.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED)) {
return;
}
if (strCommand == NetMsgType::CLSIG) {
CChainLockSig clsig;
vRecv >> clsig;
@ -171,6 +176,9 @@ void CChainLocksHandler::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBl
if (!pindexNew->pprev) {
return;
}
if (!sporkManager.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED)) {
return;
}
// DIP8 defines a process called "Signing attempts" which should run before the CLSIG is finalized
// To simplify the initial implementation, we skip this process and directly try to create a CLSIG
@ -257,6 +265,10 @@ void CChainLocksHandler::EnforceBestChainLock()
void CChainLocksHandler::HandleNewRecoveredSig(const llmq::CRecoveredSig& recoveredSig)
{
if (!sporkManager.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED)) {
return;
}
CChainLockSig clsig;
{
LOCK(cs);
@ -316,6 +328,10 @@ void CChainLocksHandler::DoInvalidateBlock(const CBlockIndex* pindex, bool activ
bool CChainLocksHandler::HasChainLock(int nHeight, const uint256& blockHash)
{
if (!sporkManager.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED)) {
return false;
}
LOCK(cs);
return InternalHasChainLock(nHeight, blockHash);
}
@ -342,6 +358,10 @@ bool CChainLocksHandler::InternalHasChainLock(int nHeight, const uint256& blockH
bool CChainLocksHandler::HasConflictingChainLock(int nHeight, const uint256& blockHash)
{
if (!sporkManager.IsSporkActive(SPORK_19_CHAINLOCKS_ENABLED)) {
return false;
}
LOCK(cs);
return InternalHasConflictingChainLock(nHeight, blockHash);
}

View File

@ -287,6 +287,7 @@ int CSporkManager::GetSporkIDByName(const std::string& strName)
if (strName == "SPORK_16_INSTANTSEND_AUTOLOCKS") return SPORK_16_INSTANTSEND_AUTOLOCKS;
if (strName == "SPORK_17_QUORUM_DKG_ENABLED") return SPORK_17_QUORUM_DKG_ENABLED;
if (strName == "SPORK_18_QUORUM_DEBUG_ENABLED") return SPORK_18_QUORUM_DEBUG_ENABLED;
if (strName == "SPORK_19_CHAINLOCKS_ENABLED") return SPORK_19_CHAINLOCKS_ENABLED;
LogPrint("spork", "CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
return -1;
@ -304,6 +305,7 @@ std::string CSporkManager::GetSporkNameByID(int nSporkID)
case SPORK_16_INSTANTSEND_AUTOLOCKS: return "SPORK_16_INSTANTSEND_AUTOLOCKS";
case SPORK_17_QUORUM_DKG_ENABLED: return "SPORK_17_QUORUM_DKG_ENABLED";
case SPORK_18_QUORUM_DEBUG_ENABLED: return "SPORK_18_QUORUM_DEBUG_ENABLED";
case SPORK_19_CHAINLOCKS_ENABLED: return "SPORK_19_CHAINLOCKS_ENABLED";
default:
LogPrint("spork", "CSporkManager::GetSporkNameByID -- Unknown Spork ID %d\n", nSporkID);
return "Unknown";

View File

@ -26,9 +26,10 @@ static const int SPORK_12_RECONSIDER_BLOCKS = 10011;
static const int SPORK_16_INSTANTSEND_AUTOLOCKS = 10015;
static const int SPORK_17_QUORUM_DKG_ENABLED = 10016;
static const int SPORK_18_QUORUM_DEBUG_ENABLED = 10017;
static const int SPORK_19_CHAINLOCKS_ENABLED = 10018;
static const int SPORK_START = SPORK_2_INSTANTSEND_ENABLED;
static const int SPORK_END = SPORK_18_QUORUM_DEBUG_ENABLED;
static const int SPORK_END = SPORK_19_CHAINLOCKS_ENABLED;
extern std::map<int, int64_t> mapSporkDefaults;
extern CSporkManager sporkManager;