mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-21 19:34:20 +02:00
Move global scriptcheckqueue into ChainstateManager class
This commit is contained in:
@@ -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)
|
||||
void ChainstateManager::StopScriptCheckWorkerThreads()
|
||||
{
|
||||
scriptcheckqueue.StartWorkerThreads(threads_num);
|
||||
}
|
||||
|
||||
void 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();
|
||||
|
||||
Reference in New Issue
Block a user