From 7e4257254c2aae72928131abd8f24917a54eaacf Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Tue, 5 Feb 2019 15:46:05 +0100 Subject: [PATCH] Allow to override llmqChainLocks with "-llmqchainlocks" on devnet (#2683) --- src/chainparams.cpp | 10 ++++++++++ src/chainparams.h | 5 +++++ src/init.cpp | 17 +++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 5ed642cb11798..9da69c787530c 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -667,6 +667,10 @@ class CDevNetParams : public CChainParams { consensus.nHighSubsidyBlocks = nHighSubsidyBlocks; consensus.nHighSubsidyFactor = nHighSubsidyFactor; } + + void UpdateLLMQChainLocks(Consensus::LLMQType llmqType) { + consensus.llmqChainLocks = llmqType; + } }; static CDevNetParams *devNetParams; @@ -873,3 +877,9 @@ void UpdateDevnetSubsidyAndDiffParams(int nMinimumDifficultyBlocks, int nHighSub assert(devNetParams); devNetParams->UpdateSubsidyAndDiffParams(nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor); } + +void UpdateDevnetLLMQChainLocks(Consensus::LLMQType llmqType) +{ + assert(devNetParams); + devNetParams->UpdateLLMQChainLocks(llmqType); +} diff --git a/src/chainparams.h b/src/chainparams.h index a3eacd157e64e..effec7e09af6b 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -162,4 +162,9 @@ void UpdateRegtestBudgetParameters(int nMasternodePaymentsStartBlock, int nBudge */ void UpdateDevnetSubsidyAndDiffParams(int nMinimumDifficultyBlocks, int nHighSubsidyBlocks, int nHighSubsidyFactor); +/** + * Allows modifying the LLMQ type for ChainLocks. + */ +void UpdateDevnetLLMQChainLocks(Consensus::LLMQType llmqType); + #endif // BITCOIN_CHAINPARAMS_H diff --git a/src/init.cpp b/src/init.cpp index 53bbb4c076210..618452b73807e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1368,6 +1368,23 @@ bool AppInitParameterInteraction() return InitError("Difficulty and subsidy parameters may only be overridden on devnet."); } + if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) { + std::string llmqChainLocks = GetArg("-llmqchainlocks", Params().GetConsensus().llmqs.at(Params().GetConsensus().llmqChainLocks).name); + Consensus::LLMQType llmqType = Consensus::LLMQ_NONE; + for (const auto& p : Params().GetConsensus().llmqs) { + if (p.second.name == llmqChainLocks) { + llmqType = p.first; + break; + } + } + if (llmqType == Consensus::LLMQ_NONE) { + return InitError("Invalid LLMQ type specified for -llmqchainlocks."); + } + UpdateDevnetLLMQChainLocks(llmqType); + } else if (IsArgSet("-llmqchainlocks")) { + return InitError("LLMQ type for ChainLocks can only be overridden on devnet."); + } + return true; }