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.
This commit is contained in:
Kittywhiskers Van Gogh 2024-12-04 18:17:43 +00:00
parent 1e55310232
commit cc0e771c29
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
2 changed files with 6 additions and 4 deletions

View File

@ -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<CChainstateHelper>(*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});

View File

@ -54,9 +54,13 @@ LLMQContext::LLMQContext(ChainstateManager& chainman, CConnman& connman, CDeterm
}()},
ehfSignalsHandler{std::make_unique<llmq::CEHFSignalsHandler>(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();
}