Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mocknet activation params #1286

Merged
merged 1 commit into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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