Skip to content

Commit faf843c

Browse files
author
MarcoFalke
committed
refactor: Move load block thread into ChainstateManager
1 parent e08f319 commit faf843c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/init.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ static fs::path GetPidFile(const ArgsManager& args)
155155

156156
static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
157157

158-
static std::thread g_load_block;
159-
160158
void Interrupt(NodeContext& node)
161159
{
162160
InterruptHTTPServer();
@@ -220,7 +218,7 @@ void Shutdown(NodeContext& node)
220218
// After everything has been shut down, but before things get flushed, stop the
221219
// CScheduler/checkqueue, scheduler and load block thread.
222220
if (node.scheduler) node.scheduler->stop();
223-
if (g_load_block.joinable()) g_load_block.join();
221+
if (node.chainman && node.chainman->m_load_block.joinable()) node.chainman->m_load_block.join();
224222
StopScriptCheckWorkerThreads();
225223

226224
// After the threads that potentially access these pointers have been stopped,
@@ -1880,7 +1878,7 @@ bool AppInitMain(const std::any& context, NodeContext& node, interfaces::BlockAn
18801878
vImportFiles.push_back(strFile);
18811879
}
18821880

1883-
g_load_block = std::thread(&TraceThread<std::function<void()>>, "loadblk", [=, &chainman, &args] {
1881+
chainman.m_load_block = std::thread(&TraceThread<std::function<void()>>, "loadblk", [=, &chainman, &args] {
18841882
ThreadImport(chainman, vImportFiles, args);
18851883
});
18861884

src/validation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <set>
3636
#include <stdint.h>
3737
#include <string>
38+
#include <thread>
3839
#include <utility>
3940
#include <vector>
4041

@@ -869,6 +870,7 @@ class ChainstateManager
869870
friend CChain& ChainActive();
870871

871872
public:
873+
std::thread m_load_block;
872874
//! A single BlockManager instance is shared across each constructed
873875
//! chainstate to avoid duplicating block metadata.
874876
BlockManager m_blockman GUARDED_BY(::cs_main);

0 commit comments

Comments
 (0)