Skip to content

Commit fa9ebec

Browse files
author
MacroFake
committed
Remove g_parallel_script_checks
1 parent fa7c834 commit fa9ebec

File tree

5 files changed

+5
-11
lines changed

5 files changed

+5
-11
lines changed

src/checkqueue.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,12 @@ class CCheckQueue
199199
WITH_LOCK(m_mutex, m_request_stop = false);
200200
}
201201

202+
bool HasThreads() const { return !m_worker_threads.empty(); }
203+
202204
~CCheckQueue()
203205
{
204206
assert(m_worker_threads.empty());
205207
}
206-
207208
};
208209

209210
/**

src/init.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
11431143

11441144
LogPrintf("Script verification uses %d additional threads\n", script_threads);
11451145
if (script_threads >= 1) {
1146-
g_parallel_script_checks = true;
11471146
StartScriptCheckWorkerThreads(script_threads);
11481147
}
11491148

src/test/util/setup_common.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,8 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
198198
m_node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
199199
m_node.chainman->m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(m_cache_sizes.block_tree_db, true);
200200

201-
// Start script-checking threads. Set g_parallel_script_checks to true so they are used.
202201
constexpr int script_check_threads = 2;
203202
StartScriptCheckWorkerThreads(script_check_threads);
204-
g_parallel_script_checks = true;
205203
}
206204

207205
ChainTestingSetup::~ChainTestingSetup()

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ RecursiveMutex cs_main;
120120
GlobalMutex g_best_block_mutex;
121121
std::condition_variable g_best_block_cv;
122122
uint256 g_best_block;
123-
bool g_parallel_script_checks{false};
124123

125124
const CBlockIndex* Chainstate::FindForkInGlobalIndex(const CBlockLocator& locator) const
126125
{
@@ -1991,6 +1990,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
19911990

19921991
uint256 block_hash{block.GetHash()};
19931992
assert(*pindex->phashBlock == block_hash);
1993+
const bool parallel_script_checks{scriptcheckqueue.HasThreads()};
19941994

19951995
const auto time_start{SteadyClock::now()};
19961996

@@ -2179,7 +2179,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
21792179
// in multiple threads). Preallocate the vector size so a new allocation
21802180
// doesn't invalidate pointers into the vector, and keep txsdata in scope
21812181
// for as long as `control`.
2182-
CCheckQueueControl<CScriptCheck> control(fScriptChecks && g_parallel_script_checks ? &scriptcheckqueue : nullptr);
2182+
CCheckQueueControl<CScriptCheck> control(fScriptChecks && parallel_script_checks ? &scriptcheckqueue : nullptr);
21832183
std::vector<PrecomputedTransactionData> txsdata(block.vtx.size());
21842184

21852185
std::vector<int> prevheights;
@@ -2238,7 +2238,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
22382238
std::vector<CScriptCheck> vChecks;
22392239
bool fCacheResults = fJustCheck; /* Don't cache results if we're actually connecting blocks (still consult the cache, though) */
22402240
TxValidationState tx_state;
2241-
if (fScriptChecks && !CheckInputScripts(tx, tx_state, view, flags, fCacheResults, fCacheResults, txsdata[i], g_parallel_script_checks ? &vChecks : nullptr)) {
2241+
if (fScriptChecks && !CheckInputScripts(tx, tx_state, view, flags, fCacheResults, fCacheResults, txsdata[i], parallel_script_checks ? &vChecks : nullptr)) {
22422242
// Any transaction validation failure in ConnectBlock is a block consensus failure
22432243
state.Invalid(BlockValidationResult::BLOCK_CONSENSUS,
22442244
tx_state.GetRejectReason(), tx_state.GetDebugMessage());

src/validation.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ extern GlobalMutex g_best_block_mutex;
9191
extern std::condition_variable g_best_block_cv;
9292
/** Used to notify getblocktemplate RPC of new tips. */
9393
extern uint256 g_best_block;
94-
/** Whether there are dedicated script-checking threads running.
95-
* False indicates all script checking is done on the main threadMessageHandler thread.
96-
*/
97-
extern bool g_parallel_script_checks;
9894

9995
/** Documentation for argument 'checklevel'. */
10096
extern const std::vector<std::string> CHECKLEVEL_DOC;

0 commit comments

Comments
 (0)