Skip to content

Commit 0be4d71

Browse files
committed
Allow configuring target block time for a signet
1 parent d8a344e commit 0be4d71

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/chainparams.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ void ReadSigNetArgs(const ArgsManager& args, CChainParams::SigNetOptions& option
5858
}
5959
options.challenge.emplace(*val);
6060
}
61+
if (const auto signetblocktime{args.GetIntArg("-signetblocktime")}) {
62+
if (!args.IsArgSet("-signetchallenge")) {
63+
throw std::runtime_error("-signetblocktime cannot be set without -signetchallenge");
64+
}
65+
if (*signetblocktime <= 0) {
66+
throw std::runtime_error("-signetblocktime must be greater than 0");
67+
}
68+
options.pow_target_spacing = *signetblocktime;
69+
}
6170
HandleRenounceArgs(args, options.renounce);
6271
}
6372

src/chainparamsbase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman)
2323
argsman.AddArg("-renounce=deployment", "Unconditionally disable an heretical deployment attempt", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS);
2424
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);
2525
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);
26+
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);
2627
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);
2728
}
2829

src/kernel/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ class SigNetParams : public CChainParams {
485485
consensus.SegwitHeight = 1;
486486
consensus.TaprootHeight = 1;
487487
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
488-
consensus.nPowTargetSpacing = 10 * 60;
488+
consensus.nPowTargetSpacing = options.pow_target_spacing;
489489
consensus.fPowAllowMinDifficultyBlocks = false;
490490
consensus.enforce_BIP94 = false;
491491
consensus.fPowNoRetargeting = false;

src/kernel/chainparams.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class CChainParams
145145
std::optional<std::vector<uint8_t>> challenge{};
146146
std::optional<std::vector<std::string>> seeds{};
147147
RenounceParameters renounce{};
148+
int64_t pow_target_spacing{10 * 60};
148149
};
149150

150151
/**

0 commit comments

Comments
 (0)