From d024d68f0c31933ff5b5f70b361460aaa39434bf Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Wed, 25 May 2022 10:24:33 +0530 Subject: [PATCH] Fix mocknet activation params --- src/chainparams.cpp | 34 ++++++++++++++++++++++++++-------- src/init.cpp | 7 +------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 156f9b9807e..c8ae5e97fc7 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -330,15 +330,10 @@ class CMainParams : public CChainParams { /* dTxRate */ 0.1841462153145931 }; - if (fMockNetwork) { - consensus.pos.nTargetSpacing = nMockBlockTimeSecs; - consensus.pos.nTargetTimespanV2 = 10 * consensus.pos.nTargetSpacing; - // Add additional foundation members here for testing - if (!sMockFoundationPubKey.empty()) { - consensus.foundationMembers.insert(GetScriptForDestination(DecodeDestination(sMockFoundationPubKey, *this))); - } - } + UpdateActivationParametersFromArgs(); } + + void UpdateActivationParametersFromArgs(); }; /** @@ -1008,6 +1003,29 @@ void CRegTestParams::UpdateActivationParametersFromArgs() } } +void CMainParams::UpdateActivationParametersFromArgs() { + fMockNetwork = gArgs.IsArgSet("-mocknet"); + if (fMockNetwork) { + LogPrintf("============================================\n"); + LogPrintf("WARNING: MOCKNET ACTIVE. THIS IS NOT MAINNET\n"); + LogPrintf("============================================\n"); + sMockFoundationPubKey = gArgs.GetArg("-mocknet-key", ""); + nMockBlockTimeSecs = gArgs.GetArg("-mocknet-blocktime", 10); + } + + if (fMockNetwork) { + consensus.pos.nTargetSpacing = nMockBlockTimeSecs; + consensus.pos.nTargetTimespanV2 = 10 * consensus.pos.nTargetSpacing; + LogPrintf("mocknet: block-time: %s secs\n", nMockBlockTimeSecs); + // Add additional foundation members here for testing + if (!sMockFoundationPubKey.empty()) { + consensus.foundationMembers.insert(GetScriptForDestination(DecodeDestination(sMockFoundationPubKey, *this))); + LogPrintf("mocknet: key: %s\n", sMockFoundationPubKey); + } + } +} + + static std::unique_ptr globalChainParams; const CChainParams &Params() { diff --git a/src/init.cpp b/src/init.cpp index 311aaddb234..65e3d1bae15 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1219,12 +1219,7 @@ bool AppInitParameterInteraction() nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); fIsFakeNet = Params().NetworkIDString() == "regtest" && gArgs.GetArg("-dummypos", false); CTxOut::SERIALIZE_FORCED_TO_OLD_IN_TESTS = Params().NetworkIDString() == "regtest" && gArgs.GetArg("-txnotokens", false); - - fMockNetwork = gArgs.IsArgSet("-mocknet"); - if (fMockNetwork) { - sMockFoundationPubKey = gArgs.GetArg("-mocknet-key", ""); - nMockBlockTimeSecs = gArgs.GetArg("-mocknet-blocktime", 10); - } + return true; }