|
|
|
@ -377,7 +377,6 @@ void Shutdown(NodeContext& node)
|
|
|
|
|
node.chain_clients.clear();
|
|
|
|
|
if (node.validation_signals) {
|
|
|
|
|
node.validation_signals->UnregisterAllValidationInterfaces();
|
|
|
|
|
node.validation_signals->UnregisterBackgroundSignalScheduler();
|
|
|
|
|
}
|
|
|
|
|
node.mempool.reset();
|
|
|
|
|
node.fee_estimator.reset();
|
|
|
|
@ -1143,17 +1142,18 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
|
|
|
|
|
|
|
|
assert(!node.scheduler);
|
|
|
|
|
node.scheduler = std::make_unique<CScheduler>();
|
|
|
|
|
auto& scheduler = *node.scheduler;
|
|
|
|
|
|
|
|
|
|
// Start the lightweight task scheduler thread
|
|
|
|
|
node.scheduler->m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { node.scheduler->serviceQueue(); });
|
|
|
|
|
scheduler.m_service_thread = std::thread(util::TraceThread, "scheduler", [&] { scheduler.serviceQueue(); });
|
|
|
|
|
|
|
|
|
|
// Gather some entropy once per minute.
|
|
|
|
|
node.scheduler->scheduleEvery([]{
|
|
|
|
|
scheduler.scheduleEvery([]{
|
|
|
|
|
RandAddPeriodic();
|
|
|
|
|
}, std::chrono::minutes{1});
|
|
|
|
|
|
|
|
|
|
// Check disk space every 5 minutes to avoid db corruption.
|
|
|
|
|
node.scheduler->scheduleEvery([&args, &node]{
|
|
|
|
|
scheduler.scheduleEvery([&args, &node]{
|
|
|
|
|
constexpr uint64_t min_disk_space = 50 << 20; // 50 MB
|
|
|
|
|
if (!CheckDiskSpace(args.GetBlocksDirPath(), min_disk_space)) {
|
|
|
|
|
LogPrintf("Shutting down due to lack of disk space!\n");
|
|
|
|
@ -1164,9 +1164,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
|
|
|
}, std::chrono::minutes{5});
|
|
|
|
|
|
|
|
|
|
assert(!node.validation_signals);
|
|
|
|
|
node.validation_signals = std::make_unique<CMainSignals>();
|
|
|
|
|
node.validation_signals = std::make_unique<CMainSignals>(scheduler);
|
|
|
|
|
auto& validation_signals = *node.validation_signals;
|
|
|
|
|
validation_signals.RegisterBackgroundSignalScheduler(*node.scheduler);
|
|
|
|
|
|
|
|
|
|
// Create client interfaces for wallets that are supposed to be loaded
|
|
|
|
|
// according to -wallet and -disablewallet options. This only constructs
|
|
|
|
@ -1271,7 +1270,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
|
|
|
|
|
|
|
|
// Flush estimates to disk periodically
|
|
|
|
|
CBlockPolicyEstimator* fee_estimator = node.fee_estimator.get();
|
|
|
|
|
node.scheduler->scheduleEvery([fee_estimator] { fee_estimator->FlushFeeEstimates(); }, FEE_FLUSH_INTERVAL);
|
|
|
|
|
scheduler.scheduleEvery([fee_estimator] { fee_estimator->FlushFeeEstimates(); }, FEE_FLUSH_INTERVAL);
|
|
|
|
|
validation_signals.RegisterValidationInterface(fee_estimator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1910,7 +1909,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
|
|
|
|
|
|
|
|
connOptions.m_i2p_accept_incoming = args.GetBoolArg("-i2pacceptincoming", DEFAULT_I2P_ACCEPT_INCOMING);
|
|
|
|
|
|
|
|
|
|
if (!node.connman->Start(*node.scheduler, connOptions)) {
|
|
|
|
|
if (!node.connman->Start(scheduler, connOptions)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1930,15 +1929,15 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|
|
|
|
uiInterface.InitMessage(_("Done loading").translated);
|
|
|
|
|
|
|
|
|
|
for (const auto& client : node.chain_clients) {
|
|
|
|
|
client->start(*node.scheduler);
|
|
|
|
|
client->start(scheduler);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BanMan* banman = node.banman.get();
|
|
|
|
|
node.scheduler->scheduleEvery([banman]{
|
|
|
|
|
scheduler.scheduleEvery([banman]{
|
|
|
|
|
banman->DumpBanlist();
|
|
|
|
|
}, DUMP_BANS_INTERVAL);
|
|
|
|
|
|
|
|
|
|
if (node.peerman) node.peerman->StartScheduledTasks(*node.scheduler);
|
|
|
|
|
if (node.peerman) node.peerman->StartScheduledTasks(scheduler);
|
|
|
|
|
|
|
|
|
|
#if HAVE_SYSTEM
|
|
|
|
|
StartupNotify(args);
|
|
|
|
|