Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
#include <torcontrol.h> | #include <torcontrol.h> | ||||
#include <txdb.h> | #include <txdb.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <txorphanage.h> | #include <txorphanage.h> | ||||
#include <util/asmap.h> | #include <util/asmap.h> | ||||
#include <util/check.h> | #include <util/check.h> | ||||
#include <util/moneystr.h> | #include <util/moneystr.h> | ||||
#include <util/string.h> | #include <util/string.h> | ||||
#include <util/thread.h> | |||||
#include <util/threadnames.h> | #include <util/threadnames.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <validationinterface.h> | #include <validationinterface.h> | ||||
#include <walletinitinterface.h> | #include <walletinitinterface.h> | ||||
#include <boost/algorithm/string/replace.hpp> | #include <boost/algorithm/string/replace.hpp> | ||||
#include <boost/signals2/signal.hpp> | #include <boost/signals2/signal.hpp> | ||||
▲ Show 20 Lines • Show All 2,206 Lines • ▼ Show 20 Lines | bool AppInitMain(Config &config, RPCServer &rpcServer, | ||||
if (script_threads >= 1) { | if (script_threads >= 1) { | ||||
StartScriptCheckWorkerThreads(script_threads); | StartScriptCheckWorkerThreads(script_threads); | ||||
} | } | ||||
assert(!node.scheduler); | assert(!node.scheduler); | ||||
node.scheduler = std::make_unique<CScheduler>(); | node.scheduler = std::make_unique<CScheduler>(); | ||||
// Start the lightweight task scheduler thread | // Start the lightweight task scheduler thread | ||||
node.scheduler->m_service_thread = std::thread([&] { | node.scheduler->m_service_thread = | ||||
TraceThread("scheduler", [&] { node.scheduler->serviceQueue(); }); | std::thread(&util::TraceThread, "scheduler", | ||||
}); | [&] { node.scheduler->serviceQueue(); }); | ||||
// Gather some entropy once per minute. | // Gather some entropy once per minute. | ||||
node.scheduler->scheduleEvery( | node.scheduler->scheduleEvery( | ||||
[] { | [] { | ||||
RandAddPeriodic(); | RandAddPeriodic(); | ||||
return true; | return true; | ||||
}, | }, | ||||
std::chrono::minutes{1}); | std::chrono::minutes{1}); | ||||
▲ Show 20 Lines • Show All 639 Lines • ▼ Show 20 Lines | #if defined(HAVE_SYSTEM) | ||||
} | } | ||||
#endif | #endif | ||||
std::vector<fs::path> vImportFiles; | std::vector<fs::path> vImportFiles; | ||||
for (const std::string &strFile : args.GetArgs("-loadblock")) { | for (const std::string &strFile : args.GetArgs("-loadblock")) { | ||||
vImportFiles.push_back(fs::PathFromString(strFile)); | vImportFiles.push_back(fs::PathFromString(strFile)); | ||||
} | } | ||||
chainman.m_load_block = | chainman.m_load_block = std::thread( | ||||
std::thread(&TraceThread<std::function<void()>>, "loadblk", | &util::TraceThread, "loadblk", [=, &config, &chainman, &args] { | ||||
[=, &config, &chainman, &args] { | |||||
ThreadImport(config, chainman, vImportFiles, args); | ThreadImport(config, chainman, vImportFiles, args); | ||||
}); | }); | ||||
// Wait for genesis block to be processed | // Wait for genesis block to be processed | ||||
{ | { | ||||
WAIT_LOCK(g_genesis_wait_mutex, lock); | WAIT_LOCK(g_genesis_wait_mutex, lock); | ||||
// We previously could hang here if StartShutdown() is called prior to | // We previously could hang here if StartShutdown() is called prior to | ||||
// ThreadImport getting started, so instead we just wait on a timer to | // ThreadImport getting started, so instead we just wait on a timer to | ||||
// check ShutdownRequested() regularly. | // check ShutdownRequested() regularly. | ||||
while (!fHaveGenesis && !ShutdownRequested()) { | while (!fHaveGenesis && !ShutdownRequested()) { | ||||
▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines |