Allow changing BIP9 parameters on regtest
This commit is contained in:
parent
7a2d402727
commit
56c87e9211
3 changed files with 52 additions and 0 deletions
|
@ -303,6 +303,12 @@ public:
|
||||||
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
|
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
|
||||||
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
|
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
|
||||||
|
{
|
||||||
|
consensus.vDeployments[d].nStartTime = nStartTime;
|
||||||
|
consensus.vDeployments[d].nTimeout = nTimeout;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static CRegTestParams regTestParams;
|
static CRegTestParams regTestParams;
|
||||||
|
|
||||||
|
@ -331,3 +337,8 @@ void SelectParams(const std::string& network)
|
||||||
pCurrentParams = &Params(network);
|
pCurrentParams = &Params(network);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateRegtestBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
|
||||||
|
{
|
||||||
|
regTestParams.UpdateBIP9Parameters(d, nStartTime, nTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,4 +112,9 @@ CChainParams& Params(const std::string& chain);
|
||||||
*/
|
*/
|
||||||
void SelectParams(const std::string& chain);
|
void SelectParams(const std::string& chain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows modifying the BIP9 regtest parameters.
|
||||||
|
*/
|
||||||
|
void UpdateRegtestBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout);
|
||||||
|
|
||||||
#endif // BITCOIN_CHAINPARAMS_H
|
#endif // BITCOIN_CHAINPARAMS_H
|
||||||
|
|
36
src/init.cpp
36
src/init.cpp
|
@ -410,6 +410,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||||
strUsage += HelpMessageOpt("-limitancestorsize=<n>", strprintf("Do not accept transactions whose size with all in-mempool ancestors exceeds <n> kilobytes (default: %u)", DEFAULT_ANCESTOR_SIZE_LIMIT));
|
strUsage += HelpMessageOpt("-limitancestorsize=<n>", strprintf("Do not accept transactions whose size with all in-mempool ancestors exceeds <n> kilobytes (default: %u)", DEFAULT_ANCESTOR_SIZE_LIMIT));
|
||||||
strUsage += HelpMessageOpt("-limitdescendantcount=<n>", strprintf("Do not accept transactions if any ancestor would have <n> or more in-mempool descendants (default: %u)", DEFAULT_DESCENDANT_LIMIT));
|
strUsage += HelpMessageOpt("-limitdescendantcount=<n>", strprintf("Do not accept transactions if any ancestor would have <n> or more in-mempool descendants (default: %u)", DEFAULT_DESCENDANT_LIMIT));
|
||||||
strUsage += HelpMessageOpt("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT));
|
strUsage += HelpMessageOpt("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT));
|
||||||
|
strUsage += HelpMessageOpt("-bip9params=deployment:start:end", "Use given start/end times for specified bip9 deployment (regtest-only)");
|
||||||
}
|
}
|
||||||
string debugCategories = "addrman, alert, bench, coindb, db, http, libevent, lock, mempool, mempoolrej, net, proxy, prune, rand, reindex, rpc, selectcoins, tor, zmq"; // Don't translate these and qt below
|
string debugCategories = "addrman, alert, bench, coindb, db, http, libevent, lock, mempool, mempoolrej, net, proxy, prune, rand, reindex, rpc, selectcoins, tor, zmq"; // Don't translate these and qt below
|
||||||
if (mode == HMM_BITCOIN_QT)
|
if (mode == HMM_BITCOIN_QT)
|
||||||
|
@ -975,6 +976,41 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end());
|
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mapMultiArgs["-bip9params"].empty()) {
|
||||||
|
// Allow overriding bip9 parameters for testing
|
||||||
|
if (!Params().MineBlocksOnDemand()) {
|
||||||
|
return InitError("BIP9 parameters may only be overridden on regtest.");
|
||||||
|
}
|
||||||
|
const vector<string>& deployments = mapMultiArgs["-bip9params"];
|
||||||
|
for (auto i : deployments) {
|
||||||
|
std::vector<std::string> vDeploymentParams;
|
||||||
|
boost::split(vDeploymentParams, i, boost::is_any_of(":"));
|
||||||
|
if (vDeploymentParams.size() != 3) {
|
||||||
|
return InitError("BIP9 parameters malformed, expecting deployment:start:end");
|
||||||
|
}
|
||||||
|
int64_t nStartTime, nTimeout;
|
||||||
|
if (!ParseInt64(vDeploymentParams[1], &nStartTime)) {
|
||||||
|
return InitError(strprintf("Invalid nStartTime (%s)", vDeploymentParams[1]));
|
||||||
|
}
|
||||||
|
if (!ParseInt64(vDeploymentParams[2], &nTimeout)) {
|
||||||
|
return InitError(strprintf("Invalid nTimeout (%s)", vDeploymentParams[2]));
|
||||||
|
}
|
||||||
|
bool found = false;
|
||||||
|
for (int i=0; i<(int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++i)
|
||||||
|
{
|
||||||
|
if (vDeploymentParams[0].compare(VersionBitsDeploymentInfo[i].name) == 0) {
|
||||||
|
UpdateRegtestBIP9Parameters(Consensus::DeploymentPos(i), nStartTime, nTimeout);
|
||||||
|
found = true;
|
||||||
|
LogPrintf("Setting BIP9 activation parameters for %s to start=%ld, timeout=%ld\n", vDeploymentParams[0], nStartTime, nTimeout);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
return InitError(strprintf("Invalid deployment (%s)", vDeploymentParams[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
|
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
|
||||||
|
|
||||||
// Initialize elliptic curve code
|
// Initialize elliptic curve code
|
||||||
|
|
Loading…
Add table
Reference in a new issue