Skip to content

Commit d8434da

Browse files
committed
Allow configuring target block time for a signet
1 parent 369d4c0 commit d8434da

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

Diff for: src/chainparams.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ void ReadSigNetArgs(const ArgsManager& args, CChainParams::SigNetOptions& option
2727
}
2828
options.challenge.emplace(ParseHex(signet_challenge[0]));
2929
}
30+
if (const auto signetblocktime{args.GetIntArg("-signetblocktime")}) {
31+
if (!args.IsArgSet("-signetchallenge")) {
32+
throw std::runtime_error("-signetblocktime cannot be set without -signetchallenge");
33+
}
34+
if (*signetblocktime <= 0) {
35+
throw std::runtime_error("-signetblocktime must be greater than 0");
36+
}
37+
options.pow_target_spacing = *signetblocktime;
38+
}
3039
}
3140

3241
void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& options)

Diff for: src/chainparamsbase.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
2525
argsman.AddArg("-vbparams=deployment:start:end[:min_activation_height]", "Use given start/end times and min_activation_height for specified version bits deployment (regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
2626
argsman.AddArg("-signet", "Use the signet chain. Equivalent to -chain=signet. Note that the network is defined by the -signetchallenge parameter", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
2727
argsman.AddArg("-signetchallenge", "Blocks must satisfy the given script to be considered valid (only for signet networks; defaults to the global default signet test network challenge)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
28+
argsman.AddArg("-signetblocktime", "Difficulty adjustment will target a block time of the given amount in seconds (only for custom signet networks, must have -signetchallenge set; defaults to 10 minutes)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
2829
argsman.AddArg("-signetseednode", "Specify a seed node for the signet network, in the hostname[:port] format, e.g. sig.net:1234 (may be used multiple times to specify multiple seed nodes; defaults to the global default signet test network seed node(s))", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_NEGATION, OptionsCategory::CHAINPARAMS);
2930
}
3031

Diff for: src/kernel/chainparams.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ class SigNetParams : public CChainParams {
339339
consensus.CSVHeight = 1;
340340
consensus.SegwitHeight = 1;
341341
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
342-
consensus.nPowTargetSpacing = 10 * 60;
342+
consensus.nPowTargetSpacing = options.pow_target_spacing;
343343
consensus.fPowAllowMinDifficultyBlocks = false;
344344
consensus.fPowNoRetargeting = false;
345345
consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016

Diff for: src/kernel/chainparams.h

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class CChainParams
135135
struct SigNetOptions {
136136
std::optional<std::vector<uint8_t>> challenge{};
137137
std::optional<std::vector<std::string>> seeds{};
138+
int64_t pow_target_spacing{10 * 60};
138139
};
139140

140141
/**

0 commit comments

Comments
 (0)