Skip to content

Commit f6b02b7

Browse files
committed
refactor: move CDKGSessionManager thread management to ActiveContext
1 parent 74afa28 commit f6b02b7

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
22562256

22572257
// ********************************************************* Step 10a: schedule Dash-specific tasks
22582258

2259-
node.llmq_ctx->Start(*node.connman, *node.peerman);
2259+
node.llmq_ctx->Start(*node.peerman);
22602260
if (node.active_ctx) node.active_ctx->Start(*node.connman, *node.peerman);
22612261

22622262
node.scheduler->scheduleEvery(std::bind(&CNetFulfilledRequestManager::DoMaintenance, std::ref(*node.netfulfilledman)), std::chrono::minutes{1});

src/llmq/context.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ LLMQContext::LLMQContext(ChainstateManager& chainman, CDeterministicMNManager& d
1919
CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, CSporkManager& sporkman,
2020
CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman,
2121
const CMasternodeSync& mn_sync, bool unit_tests, bool wipe) :
22-
is_masternode{mn_activeman != nullptr},
2322
bls_worker{std::make_shared<CBLSWorker>()},
2423
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
2524
qsnapman{std::make_unique<llmq::CQuorumSnapshotManager>(evo_db)},
@@ -49,23 +48,18 @@ void LLMQContext::Interrupt() {
4948
sigman->InterruptWorkerThread();
5049
}
5150

52-
void LLMQContext::Start(CConnman& connman, PeerManager& peerman)
51+
void LLMQContext::Start(PeerManager& peerman)
5352
{
54-
if (is_masternode) {
55-
qdkgsman->StartThreads(connman, peerman);
56-
}
5753
qman->Start();
5854
sigman->StartWorkerThread(peerman);
5955
clhandler->Start(*isman);
6056
isman->Start(peerman);
6157
}
6258

63-
void LLMQContext::Stop() {
59+
void LLMQContext::Stop()
60+
{
6461
isman->Stop();
6562
clhandler->Stop();
6663
sigman->StopWorkerThread();
6764
qman->Stop();
68-
if (is_masternode) {
69-
qdkgsman->StopThreads();
70-
}
7165
}

src/llmq/context.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
class CActiveMasternodeManager;
1111
class CBLSWorker;
12-
class CConnman;
1312
class ChainstateManager;
1413
class CDeterministicMNManager;
1514
class CEvoDB;
@@ -32,9 +31,6 @@ class CSigningManager;
3231
}
3332

3433
struct LLMQContext {
35-
private:
36-
const bool is_masternode;
37-
3834
public:
3935
LLMQContext() = delete;
4036
LLMQContext(const LLMQContext&) = delete;
@@ -45,7 +41,7 @@ struct LLMQContext {
4541
~LLMQContext();
4642

4743
void Interrupt();
48-
void Start(CConnman& connman, PeerManager& peerman);
44+
void Start(PeerManager& peerman);
4945
void Stop();
5046

5147
/** Guaranteed if LLMQContext is initialized then all members are valid too

src/masternode/active/context.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <instantsend/instantsend.h>
1313
#include <instantsend/signing.h>
1414
#include <llmq/context.h>
15+
#include <llmq/dkgsessionmgr.h>
1516
#include <llmq/ehf_signals.h>
1617
#include <llmq/signing_shares.h>
1718
#include <validation.h>
@@ -51,6 +52,7 @@ void ActiveContext::Interrupt()
5152

5253
void ActiveContext::Start(CConnman& connman, PeerManager& peerman)
5354
{
55+
m_llmq_ctx.qdkgsman->StartThreads(connman, peerman);
5456
shareman->RegisterAsRecoveredSigsListener();
5557
shareman->StartWorkerThread(connman, peerman);
5658
}
@@ -59,4 +61,5 @@ void ActiveContext::Stop()
5961
{
6062
shareman->StopWorkerThread();
6163
shareman->UnregisterAsRecoveredSigsListener();
64+
m_llmq_ctx.qdkgsman->StopThreads();
6265
}

0 commit comments

Comments
 (0)