Skip to content

Commit

Permalink
Add SPORK_19_CHAINLOCKS_ENABLED
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jan 28, 2019
1 parent 29532ba commit 135829d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/llmq/quorums_chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "chain.h"
#include "net_processing.h"
#include "scheduler.h"
#include "spork.h"
#include "validation.h"

namespace llmq
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/spork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion src/spork.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 135829d

Please sign in to comment.