Skip to content

Commit ecb924c

Browse files
committed
refactor: move EHF signals handler to ActiveContext
1 parent 83707a0 commit ecb924c

File tree

10 files changed

+28
-22
lines changed

10 files changed

+28
-22
lines changed

src/dsnotificationinterface.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
9292

9393
m_llmq_ctx->qman->UpdatedBlockTip(pindexNew, m_connman, fInitialDownload);
9494
m_llmq_ctx->qdkgsman->UpdatedBlockTip(pindexNew, fInitialDownload);
95-
m_llmq_ctx->ehfSignalsHandler->UpdatedBlockTip(pindexNew, /* is_masternode = */ m_mn_activeman != nullptr);
9695

9796
if (m_govman.IsValid()) {
9897
m_govman.UpdatedBlockTip(pindexNew, m_connman, m_peerman, m_mn_activeman);

src/init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,10 +2167,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
21672167
assert(!node.active_ctx);
21682168
assert(!g_active_notification_interface);
21692169
if (node.mn_activeman) {
2170-
node.active_ctx = std::make_unique<ActiveContext>(chainman, *node.connman, *node.dmnman, *node.cj_ctx->dstxman, *node.mn_metaman,
2170+
node.active_ctx = std::make_unique<ActiveContext>(chainman, *node.connman, *node.dmnman, *node.cj_ctx->dstxman, *node.mn_metaman, *node.mnhf_manager,
21712171
*node.llmq_ctx, *node.sporkman, *node.mempool, *node.peerman, *node.mn_activeman,
21722172
*node.mn_sync);
2173-
g_active_notification_interface = std::make_unique<ActiveNotificationInterface>(*node.mn_activeman);
2173+
g_active_notification_interface = std::make_unique<ActiveNotificationInterface>(*node.active_ctx, *node.mn_activeman);
21742174
RegisterValidationInterface(g_active_notification_interface.get());
21752175
}
21762176

src/llmq/context.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <llmq/blockprocessor.h>
1111
#include <llmq/debug.h>
1212
#include <llmq/dkgsessionmgr.h>
13-
#include <llmq/ehf_signals.h>
1413
#include <llmq/quorums.h>
1514
#include <llmq/signing.h>
1615
#include <llmq/signing_shares.h>
@@ -38,8 +37,7 @@ LLMQContext::LLMQContext(ChainstateManager& chainman, CDeterministicMNManager& d
3837
clhandler{std::make_unique<llmq::CChainLocksHandler>(chainman.ActiveChainstate(), *qman, *sigman, sporkman, mempool,
3938
mn_sync)},
4039
isman{std::make_unique<llmq::CInstantSendManager>(*clhandler, chainman.ActiveChainstate(), *qman, *sigman, sporkman,
41-
mempool, mn_sync, unit_tests, wipe)},
42-
ehfSignalsHandler{std::make_unique<llmq::CEHFSignalsHandler>(chainman, mnhfman, *sigman, *shareman, *qman)}
40+
mempool, mn_sync, unit_tests, wipe)}
4341
{
4442
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase
4543
bls_worker->Start();

src/llmq/context.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace llmq {
2424
class CChainLocksHandler;
2525
class CDKGDebugManager;
2626
class CDKGSessionManager;
27-
class CEHFSignalsHandler;
2827
class CInstantSendManager;
2928
class CQuorumBlockProcessor;
3029
class CQuorumManager;
@@ -70,7 +69,6 @@ struct LLMQContext {
7069
const std::unique_ptr<llmq::CSigSharesManager> shareman;
7170
const std::unique_ptr<llmq::CChainLocksHandler> clhandler;
7271
const std::unique_ptr<llmq::CInstantSendManager> isman;
73-
const std::unique_ptr<llmq::CEHFSignalsHandler> ehfSignalsHandler;
7472
};
7573

7674
#endif // BITCOIN_LLMQ_CONTEXT_H

src/llmq/ehf_signals.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,10 @@ CEHFSignalsHandler::~CEHFSignalsHandler()
3434
sigman.UnregisterRecoveredSigsListener(this);
3535
}
3636

37-
void CEHFSignalsHandler::UpdatedBlockTip(const CBlockIndex* const pindexNew, bool is_masternode)
37+
void CEHFSignalsHandler::UpdatedBlockTip(const CBlockIndex* const pindexNew)
3838
{
3939
if (!DeploymentActiveAfter(pindexNew, Params().GetConsensus(), Consensus::DEPLOYMENT_V20)) return;
4040

41-
if (!is_masternode) {
42-
return;
43-
}
44-
4541
const auto ehfSignals = mnhfman.GetSignalsStage(pindexNew);
4642
for (const auto& deployment : Params().GetConsensus().vDeployments) {
4743
// Skip deployments that do not use dip0023

src/llmq/ehf_signals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CEHFSignalsHandler : public CRecoveredSigsListener
4343
/**
4444
* Since Tip is updated it could be a time to generate EHF Signal
4545
*/
46-
void UpdatedBlockTip(const CBlockIndex* const pindexNew, bool is_masternode) EXCLUSIVE_LOCKS_REQUIRED(!cs);
46+
void UpdatedBlockTip(const CBlockIndex* const pindexNew) EXCLUSIVE_LOCKS_REQUIRED(!cs);
4747

4848
[[nodiscard]] MessageProcessingResult HandleNewRecoveredSig(const CRecoveredSig& recoveredSig) override
4949
EXCLUSIVE_LOCKS_REQUIRED(!cs);

src/masternode/active/context.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
#include <instantsend/instantsend.h>
1111
#include <instantsend/signing.h>
1212
#include <llmq/context.h>
13+
#include <llmq/ehf_signals.h>
1314
#include <validation.h>
1415

1516
ActiveContext::ActiveContext(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman,
16-
CDSTXManager& dstxman, CMasternodeMetaMan& mn_metaman, LLMQContext& llmq_ctx,
17-
CSporkManager& sporkman, CTxMemPool& mempool, PeerManager& peerman,
17+
CDSTXManager& dstxman, CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman,
18+
LLMQContext& llmq_ctx, CSporkManager& sporkman, CTxMemPool& mempool, PeerManager& peerman,
1819
const CActiveMasternodeManager& mn_activeman, const CMasternodeSync& mn_sync) :
1920
m_llmq_ctx{llmq_ctx},
2021
cl_signer{std::make_unique<chainlock::ChainLockSigner>(chainman.ActiveChainstate(), *llmq_ctx.clhandler,
@@ -23,7 +24,9 @@ ActiveContext::ActiveContext(ChainstateManager& chainman, CConnman& connman, CDe
2324
*llmq_ctx.isman, *llmq_ctx.sigman, *llmq_ctx.shareman,
2425
*llmq_ctx.qman, sporkman, mempool, mn_sync)},
2526
cj_server{std::make_unique<CCoinJoinServer>(chainman, connman, dmnman, dstxman, mn_metaman, mempool, peerman,
26-
mn_activeman, mn_sync, *llmq_ctx.isman)}
27+
mn_activeman, mn_sync, *llmq_ctx.isman)},
28+
ehf_sighandler{std::make_unique<llmq::CEHFSignalsHandler>(chainman, mnhfman, *llmq_ctx.sigman, *llmq_ctx.shareman,
29+
*llmq_ctx.qman)}
2730
{
2831
m_llmq_ctx.clhandler->ConnectSigner(cl_signer.get());
2932
m_llmq_ctx.isman->ConnectSigner(is_signer.get());

src/masternode/active/context.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class CDeterministicMNManager;
1515
class CDSTXManager;
1616
class CMasternodeMetaMan;
1717
class CMasternodeSync;
18+
class CMNHFManager;
1819
class CSporkManager;
1920
class CTxMemPool;
2021
class PeerManager;
@@ -25,6 +26,9 @@ class ChainLockSigner;
2526
namespace instantsend {
2627
class InstantSendSigner;
2728
} // namespace instantsend
29+
namespace llmq {
30+
class CEHFSignalsHandler;
31+
} // namespace llmq
2832

2933
struct ActiveContext {
3034
private:
@@ -41,9 +45,10 @@ struct ActiveContext {
4145
public:
4246
ActiveContext() = delete;
4347
ActiveContext(const ActiveContext&) = delete;
44-
ActiveContext(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman, CDSTXManager& dstxman,
45-
CMasternodeMetaMan& mn_metaman, LLMQContext& llmq_ctx, CSporkManager& sporkman, CTxMemPool& mempool,
46-
PeerManager& peerman, const CActiveMasternodeManager& mn_activeman, const CMasternodeSync& mn_sync);
48+
ActiveContext(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman,
49+
CDSTXManager& dstxman, CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, LLMQContext& llmq_ctx,
50+
CSporkManager& sporkman, CTxMemPool& mempool, PeerManager& peerman,
51+
const CActiveMasternodeManager& mn_activeman, const CMasternodeSync& mn_sync);
4752
~ActiveContext();
4853

4954
/*
@@ -52,6 +57,7 @@ struct ActiveContext {
5257
* TODO: Move CActiveMasternodeManager here when dependents have been migrated
5358
*/
5459
const std::unique_ptr<CCoinJoinServer> cj_server;
60+
const std::unique_ptr<llmq::CEHFSignalsHandler> ehf_sighandler;
5561
};
5662

5763
#endif // BITCOIN_MASTERNODE_ACTIVE_CONTEXT_H

src/masternode/active/notificationinterface.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
#include <masternode/active/notificationinterface.h>
66

7+
#include <llmq/ehf_signals.h>
8+
#include <masternode/active/context.h>
79
#include <masternode/node.h>
810

9-
ActiveNotificationInterface::ActiveNotificationInterface(CActiveMasternodeManager& mn_activeman) :
11+
ActiveNotificationInterface::ActiveNotificationInterface(ActiveContext& active_ctx, CActiveMasternodeManager& mn_activeman) :
12+
m_active_ctx{active_ctx},
1013
m_mn_activeman{mn_activeman}
1114
{
1215
}
@@ -18,6 +21,7 @@ void ActiveNotificationInterface::UpdatedBlockTip(const CBlockIndex* pindexNew,
1821
return;
1922

2023
m_mn_activeman.UpdatedBlockTip(pindexNew, pindexFork, fInitialDownload);
24+
m_active_ctx.ehf_sighandler->UpdatedBlockTip(pindexNew);
2125
}
2226

2327
std::unique_ptr<ActiveNotificationInterface> g_active_notification_interface;

src/masternode/active/notificationinterface.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@
88
#include <validationinterface.h>
99

1010
class CActiveMasternodeManager;
11+
struct ActiveContext;
1112

1213
class ActiveNotificationInterface final : public CValidationInterface
1314
{
1415
public:
1516
ActiveNotificationInterface() = delete;
1617
ActiveNotificationInterface(const ActiveNotificationInterface&) = delete;
17-
explicit ActiveNotificationInterface(CActiveMasternodeManager& mn_activeman);
18+
explicit ActiveNotificationInterface(ActiveContext& active_ctx, CActiveMasternodeManager& mn_activeman);
1819
virtual ~ActiveNotificationInterface() = default;
1920

2021
protected:
2122
// CValidationInterface
2223
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override;
2324

2425
private:
26+
ActiveContext& m_active_ctx;
2527
CActiveMasternodeManager& m_mn_activeman;
2628
};
2729

0 commit comments

Comments
 (0)