forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathcontext.cpp
More file actions
120 lines (103 loc) · 4.51 KB
/
Copy pathcontext.cpp
File metadata and controls
120 lines (103 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright (c) 2025 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <active/context.h>
#include <active/masternode.h>
#include <bls/bls_worker.h>
#include <chainlock/handler.h>
#include <chainlock/signing.h>
#include <evo/deterministicmns.h>
#include <governance/governance.h>
#include <governance/signing.h>
#include <instantsend/instantsend.h>
#include <instantsend/signing.h>
#include <llmq/debug.h>
#include <llmq/dkgsessionmgr.h>
#include <llmq/ehf_signals.h>
#include <llmq/quorums.h>
#include <llmq/quorumsman.h>
#include <llmq/signing_shares.h>
#include <masternode/sync.h>
#include <util/check.h>
#include <validation.h>
#include <validationinterface.h>
ActiveContext::ActiveContext(CBLSWorker& bls_worker, ChainstateManager& chainman, CConnman& connman,
CDeterministicMNManager& dmnman, CGovernanceManager& govman, CSporkManager& sporkman,
const chainlock::Chainlocks& chainlocks, CTxMemPool& mempool,
chainlock::ChainlockHandler& clhandler, llmq::CInstantSendManager& isman,
llmq::CQuorumManager& qman, llmq::CQuorumSnapshotManager& qsnapman,
llmq::CSigningManager& sigman, const CMasternodeSync& mn_sync,
const CBLSSecretKey& operator_sk, const util::DbWrapperParams& db_params, bool quorums_watch) :
llmq::QuorumRole{qman},
m_bls_worker{bls_worker},
m_quorums_watch{quorums_watch},
nodeman{std::make_unique<CActiveMasternodeManager>(connman, dmnman, operator_sk)},
dkgdbgman{std::make_unique<llmq::CDKGDebugManager>(dmnman, qsnapman, chainman)},
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(dmnman, qsnapman, chainman, sporkman, db_params)},
shareman{std::make_unique<llmq::CSigSharesManager>(connman, chainman, sigman, *nodeman, qman, sporkman)},
gov_signer{std::make_unique<GovernanceSigner>(connman, dmnman, govman, *nodeman, chainman, mn_sync)},
ehf_sighandler{std::make_unique<llmq::CEHFSignalsHandler>(chainman, sigman, *shareman, qman)},
cl_signer{std::make_unique<chainlock::ChainLockSigner>(chainman.ActiveChainstate(), chainlocks, clhandler, isman,
qman, sigman, *shareman, mn_sync)},
is_signer{std::make_unique<instantsend::InstantSendSigner>(chainman.ActiveChainstate(), chainlocks, isman, sigman,
*shareman, qman, sporkman, mempool, mn_sync)}
{
}
ActiveContext::~ActiveContext() = default;
void ActiveContext::Start()
{
cl_signer->Start();
cl_signer->RegisterRecoveryInterface();
is_signer->RegisterRecoveryInterface();
shareman->RegisterRecoveryInterface();
RegisterValidationInterface(cl_signer.get());
}
void ActiveContext::Stop()
{
UnregisterValidationInterface(cl_signer.get());
shareman->UnregisterRecoveryInterface();
is_signer->UnregisterRecoveryInterface();
cl_signer->UnregisterRecoveryInterface();
cl_signer->Stop();
}
CCoinJoinServer& ActiveContext::GetCJServer() const
{
return *Assert(m_cj_server);
}
void ActiveContext::SetCJServer(gsl::not_null<CCoinJoinServer*> cj_server)
{
// Prohibit double initialization
assert(m_cj_server == nullptr);
m_cj_server = cj_server;
}
void ActiveContext::InitializeCurrentBlockTip(const CBlockIndex* tip, bool ibd)
{
UpdatedBlockTip(tip, nullptr, ibd);
}
void ActiveContext::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload)
{
if (fInitialDownload || pindexNew == pindexFork) // In IBD or blocks were disconnected without any new ones
return;
nodeman->UpdatedBlockTip(pindexNew, pindexFork, fInitialDownload);
ehf_sighandler->UpdatedBlockTip(pindexNew);
gov_signer->UpdatedBlockTip(pindexNew);
qdkgsman->UpdatedBlockTip(pindexNew, fInitialDownload);
}
bool ActiveContext::IsMasternode() const
{
// We are only initialized if masternode mode is enabled
return true;
}
bool ActiveContext::IsWatching() const
{
// Watch-only mode can co-exist with masternode mode
return m_quorums_watch;
}
uint256 ActiveContext::GetProTxHash() const
{
return nodeman->GetProTxHash();
}
bool ActiveContext::SetQuorumSecretKeyShare(llmq::CQuorum& quorum, Span<CBLSSecretKey> skContributions) const
{
return quorum.SetSecretKeyShare(m_bls_worker.AggregateSecretKeys(skContributions), nodeman->GetProTxHash());
}