From cc0e771c291750f73e0772ebfe27340f65140dc6 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:17:43 +0000 Subject: [PATCH] refactor: start BLS thread in `LLMQContext` ctor, move `Start` downwards Alternate fix as proposed in dash#5752, needed because dependencies for threaded logic will be pulled out of ctor in upcoming commits and that needs `Start` to be pushed downwards so we can avoid having to pass `unique_ptr` references. --- src/init.cpp | 4 ++-- src/llmq/context.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 1abb710513..7eb9992f34 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1906,8 +1906,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) *node.mempool, node.mn_activeman.get(), *node.mn_sync, node.peerman, /* unit_tests = */ false, /* wipe = */ fReset || fReindexChainState); // Enable CMNHFManager::{Process, Undo}Block node.mnhf_manager->ConnectManagers(node.chainman.get(), node.llmq_ctx->qman.get()); - // Have to start it early to let VerifyDB check ChainLock signatures in coinbase - node.llmq_ctx->Start(); node.chain_helper.reset(); node.chain_helper = std::make_unique(*node.cpoolman, *node.dmnman, *node.mnhf_manager, *node.govman, *(node.llmq_ctx->quorum_block_processor), *node.chainman, @@ -2282,6 +2280,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) // ********************************************************* Step 10a: schedule Dash-specific tasks + node.llmq_ctx->Start(); + node.scheduler->scheduleEvery(std::bind(&CNetFulfilledRequestManager::DoMaintenance, std::ref(*node.netfulfilledman)), std::chrono::minutes{1}); node.scheduler->scheduleEvery(std::bind(&CMasternodeSync::DoMaintenance, std::ref(*node.mn_sync), std::cref(*node.peerman), std::cref(*node.govman)), std::chrono::seconds{1}); node.scheduler->scheduleEvery(std::bind(&CMasternodeUtils::DoMaintenance, std::ref(*node.connman), std::ref(*node.dmnman), std::ref(*node.mn_sync), std::ref(*node.cj_ctx)), std::chrono::minutes{1}); diff --git a/src/llmq/context.cpp b/src/llmq/context.cpp index 2d58262f80..80c321f332 100644 --- a/src/llmq/context.cpp +++ b/src/llmq/context.cpp @@ -54,9 +54,13 @@ LLMQContext::LLMQContext(ChainstateManager& chainman, CConnman& connman, CDeterm }()}, ehfSignalsHandler{std::make_unique(chainman, mnhfman, *sigman, *shareman, *qman)} { + // Have to start it early to let VerifyDB check ChainLock signatures in coinbase + bls_worker->Start(); } LLMQContext::~LLMQContext() { + bls_worker->Stop(); + // LLMQContext doesn't own these objects, but still need to care of them for consistency: llmq::quorumInstantSendManager.reset(); llmq::chainLocksHandler.reset(); @@ -74,7 +78,6 @@ void LLMQContext::Start() { assert(clhandler == llmq::chainLocksHandler.get()); assert(isman == llmq::quorumInstantSendManager.get()); - bls_worker->Start(); if (is_masternode) { qdkgsman->StartThreads(); } @@ -101,5 +104,4 @@ void LLMQContext::Stop() { if (is_masternode) { qdkgsman->StopThreads(); } - bls_worker->Stop(); }