mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
refactor: Move load block thread into ChainstateManager
This commit is contained in:
@@ -155,8 +155,6 @@ static fs::path GetPidFile(const ArgsManager& args)
|
|||||||
|
|
||||||
static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
|
static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
|
||||||
|
|
||||||
static std::thread g_load_block;
|
|
||||||
|
|
||||||
void Interrupt(NodeContext& node)
|
void Interrupt(NodeContext& node)
|
||||||
{
|
{
|
||||||
InterruptHTTPServer();
|
InterruptHTTPServer();
|
||||||
@@ -220,7 +218,7 @@ void Shutdown(NodeContext& node)
|
|||||||
// After everything has been shut down, but before things get flushed, stop the
|
// After everything has been shut down, but before things get flushed, stop the
|
||||||
// CScheduler/checkqueue, scheduler and load block thread.
|
// CScheduler/checkqueue, scheduler and load block thread.
|
||||||
if (node.scheduler) node.scheduler->stop();
|
if (node.scheduler) node.scheduler->stop();
|
||||||
if (g_load_block.joinable()) g_load_block.join();
|
if (node.chainman && node.chainman->m_load_block.joinable()) node.chainman->m_load_block.join();
|
||||||
StopScriptCheckWorkerThreads();
|
StopScriptCheckWorkerThreads();
|
||||||
|
|
||||||
// After the threads that potentially access these pointers have been stopped,
|
// 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
|
|||||||
vImportFiles.push_back(strFile);
|
vImportFiles.push_back(strFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_load_block = std::thread(&TraceThread<std::function<void()>>, "loadblk", [=, &chainman, &args] {
|
chainman.m_load_block = std::thread(&TraceThread<std::function<void()>>, "loadblk", [=, &chainman, &args] {
|
||||||
ThreadImport(chainman, vImportFiles, args);
|
ThreadImport(chainman, vImportFiles, args);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -869,6 +870,7 @@ private:
|
|||||||
friend CChain& ChainActive();
|
friend CChain& ChainActive();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
std::thread m_load_block;
|
||||||
//! A single BlockManager instance is shared across each constructed
|
//! A single BlockManager instance is shared across each constructed
|
||||||
//! chainstate to avoid duplicating block metadata.
|
//! chainstate to avoid duplicating block metadata.
|
||||||
BlockManager m_blockman GUARDED_BY(::cs_main);
|
BlockManager m_blockman GUARDED_BY(::cs_main);
|
||||||
|
|||||||
Reference in New Issue
Block a user