mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-11 09:42:17 +01:00
validation: allow to specify frequency for -checkblockindex
This makes it similar to -checkaddrman and -checkmempool, which also allow to run the check occasionally instead of always / never. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -5034,6 +5034,14 @@ void ChainstateManager::LoadExternalBlockFile(
|
||||
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, Ticks<std::chrono::milliseconds>(SteadyClock::now() - start));
|
||||
}
|
||||
|
||||
bool ChainstateManager::ShouldCheckBlockIndex() const
|
||||
{
|
||||
// Assert to verify Flatten() has been called.
|
||||
if (!*Assert(m_options.check_block_index)) return false;
|
||||
if (GetRand(*m_options.check_block_index) >= 1) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChainstateManager::CheckBlockIndex()
|
||||
{
|
||||
if (!ShouldCheckBlockIndex()) {
|
||||
|
||||
Reference in New Issue
Block a user