aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 30b3dde74f..f744126c9f 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2047,16 +2047,9 @@ DisconnectResult Chainstate::DisconnectBlock(const CBlock& block, const CBlockIn
return fClean ? DISCONNECT_OK : DISCONNECT_UNCLEAN;
}
-static CCheckQueue<CScriptCheck> scriptcheckqueue(128);
-
-void StartScriptCheckWorkerThreads(int threads_num)
-{
- scriptcheckqueue.StartWorkerThreads(threads_num);
-}
-
-void StopScriptCheckWorkerThreads()
+void ChainstateManager::StopScriptCheckWorkerThreads()
{
- scriptcheckqueue.StopWorkerThreads();
+ m_script_check_queue.StopWorkerThreads();
}
/**
@@ -2147,7 +2140,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
uint256 block_hash{block.GetHash()};
assert(*pindex->phashBlock == block_hash);
- const bool parallel_script_checks{scriptcheckqueue.HasThreads()};
+ const bool parallel_script_checks{m_chainman.GetCheckQueue().HasThreads()};
const auto time_start{SteadyClock::now()};
const CChainParams& params{m_chainman.GetParams()};
@@ -2336,7 +2329,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
// in multiple threads). Preallocate the vector size so a new allocation
// doesn't invalidate pointers into the vector, and keep txsdata in scope
// for as long as `control`.
- CCheckQueueControl<CScriptCheck> control(fScriptChecks && parallel_script_checks ? &scriptcheckqueue : nullptr);
+ CCheckQueueControl<CScriptCheck> control(fScriptChecks && parallel_script_checks ? &m_chainman.GetCheckQueue() : nullptr);
std::vector<PrecomputedTransactionData> txsdata(block.vtx.size());
std::vector<int> prevheights;
@@ -5751,12 +5744,18 @@ static ChainstateManager::Options&& Flatten(ChainstateManager::Options&& opts)
}
ChainstateManager::ChainstateManager(const util::SignalInterrupt& interrupt, Options options, node::BlockManager::Options blockman_options)
- : m_interrupt{interrupt},
+ : m_script_check_queue{/*nBatchSizeIn=*/128},
+ m_interrupt{interrupt},
m_options{Flatten(std::move(options))},
- m_blockman{interrupt, std::move(blockman_options)} {}
+ m_blockman{interrupt, std::move(blockman_options)}
+{
+ m_script_check_queue.StartWorkerThreads(m_options.worker_threads_num);
+}
ChainstateManager::~ChainstateManager()
{
+ StopScriptCheckWorkerThreads();
+
LOCK(::cs_main);
m_versionbitscache.Clear();