Skip to content

Commit

Permalink
Fix mocknet activation params (#1286)
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl authored May 25, 2022
1 parent 7c8e1a6 commit f6fdfec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
34 changes: 26 additions & 8 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

/**
Expand Down Expand Up @@ -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<const CChainParams> globalChainParams;

const CChainParams &Params() {
Expand Down
7 changes: 1 addition & 6 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f6fdfec

Please sign in to comment.