miner: have waitNext return after 20 min on testnet

On testnet we need to create a min diff template after 20 min.
This commit is contained in:
Sjors Provoost
2025-01-31 17:19:28 +01:00
parent d4020f502a
commit cadbd4137d
5 changed files with 94 additions and 0 deletions

View File

@@ -958,6 +958,7 @@ public:
auto now{NodeClock::now()};
const auto deadline = now + options.timeout;
const MillisecondsDouble tick{1000};
const bool allow_min_difficulty{chainman().GetParams().GetConsensus().fPowAllowMinDifficultyBlocks};
do {
bool tip_changed{false};
@@ -982,6 +983,14 @@ public:
// Must release m_tip_block_mutex before locking cs_main, to avoid deadlocks.
LOCK(::cs_main);
// On test networks return a minimum difficulty block after 20 minutes
if (!tip_changed && allow_min_difficulty) {
const NodeClock::time_point tip_time{std::chrono::seconds{chainman().ActiveChain().Tip()->GetBlockTime()}};
if (now > tip_time + 20min) {
tip_changed = true;
}
}
/**
* We determine if fees increased compared to the previous template by generating
* a fresh template. There may be more efficient ways to determine how much