mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
refactor: remove llmq::CQuorumManager
global, move to LLMQContext
This commit is contained in:
parent
5b86df6ca3
commit
d7c35d0538
@ -1975,7 +1975,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman,
|
||||
*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.llmq_ctx->qman);
|
||||
node.mnhf_manager->ConnectManagers(node.llmq_ctx->qman.get());
|
||||
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase
|
||||
node.llmq_ctx->Start();
|
||||
|
||||
|
@ -26,24 +26,20 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis
|
||||
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
|
||||
quorum_block_processor{std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, dmnman, evo_db, peerman)},
|
||||
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, dmnman, *dkg_debugman, mn_metaman, *quorum_block_processor, mn_activeman, sporkman, peerman, unit_tests, wipe)},
|
||||
qman{[&]() -> llmq::CQuorumManager* const {
|
||||
assert(llmq::quorumManager == nullptr);
|
||||
llmq::quorumManager = std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, dmnman, *qdkgsman, evo_db, *quorum_block_processor, mn_activeman, mn_sync, sporkman);
|
||||
return llmq::quorumManager.get();
|
||||
}()},
|
||||
sigman{std::make_unique<llmq::CSigningManager>(connman, mn_activeman, *llmq::quorumManager, peerman, unit_tests, wipe)},
|
||||
shareman{std::make_unique<llmq::CSigSharesManager>(connman, *sigman, mn_activeman, *llmq::quorumManager, sporkman, peerman)},
|
||||
qman{std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, dmnman, *qdkgsman, evo_db, *quorum_block_processor, mn_activeman, mn_sync, sporkman)},
|
||||
sigman{std::make_unique<llmq::CSigningManager>(connman, mn_activeman, *qman, peerman, unit_tests, wipe)},
|
||||
shareman{std::make_unique<llmq::CSigSharesManager>(connman, *sigman, mn_activeman, *qman, sporkman, peerman)},
|
||||
clhandler{[&]() -> llmq::CChainLocksHandler* const {
|
||||
assert(llmq::chainLocksHandler == nullptr);
|
||||
llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(chainstate, *llmq::quorumManager, *sigman, *shareman, sporkman, mempool, mn_sync, peerman, is_masternode);
|
||||
llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(chainstate, *qman, *sigman, *shareman, sporkman, mempool, mn_sync, peerman, is_masternode);
|
||||
return llmq::chainLocksHandler.get();
|
||||
}()},
|
||||
isman{[&]() -> llmq::CInstantSendManager* const {
|
||||
assert(llmq::quorumInstantSendManager == nullptr);
|
||||
llmq::quorumInstantSendManager = std::make_unique<llmq::CInstantSendManager>(*llmq::chainLocksHandler, chainstate, connman, *llmq::quorumManager, *sigman, *shareman, sporkman, mempool, mn_sync, peerman, is_masternode, unit_tests, wipe);
|
||||
llmq::quorumInstantSendManager = std::make_unique<llmq::CInstantSendManager>(*llmq::chainLocksHandler, chainstate, connman, *qman, *sigman, *shareman, sporkman, mempool, mn_sync, peerman, is_masternode, unit_tests, wipe);
|
||||
return llmq::quorumInstantSendManager.get();
|
||||
}()},
|
||||
ehfSignalsHandler{std::make_unique<llmq::CEHFSignalsHandler>(chainstate, mnhfman, *sigman, *shareman, mempool, *llmq::quorumManager, sporkman, peerman)}
|
||||
ehfSignalsHandler{std::make_unique<llmq::CEHFSignalsHandler>(chainstate, mnhfman, *sigman, *shareman, mempool, *qman, sporkman, peerman)}
|
||||
{
|
||||
// NOTE: we use this only to wipe the old db, do NOT use it for anything else
|
||||
// TODO: remove it in some future version
|
||||
@ -54,7 +50,6 @@ LLMQContext::~LLMQContext() {
|
||||
// LLMQContext doesn't own these objects, but still need to care of them for consistency:
|
||||
llmq::quorumInstantSendManager.reset();
|
||||
llmq::chainLocksHandler.reset();
|
||||
llmq::quorumManager.reset();
|
||||
}
|
||||
|
||||
void LLMQContext::Interrupt() {
|
||||
@ -66,7 +61,6 @@ void LLMQContext::Interrupt() {
|
||||
}
|
||||
|
||||
void LLMQContext::Start() {
|
||||
assert(qman == llmq::quorumManager.get());
|
||||
assert(clhandler == llmq::chainLocksHandler.get());
|
||||
assert(isman == llmq::quorumInstantSendManager.get());
|
||||
|
||||
@ -84,7 +78,6 @@ void LLMQContext::Start() {
|
||||
}
|
||||
|
||||
void LLMQContext::Stop() {
|
||||
assert(qman == llmq::quorumManager.get());
|
||||
assert(clhandler == llmq::chainLocksHandler.get());
|
||||
assert(isman == llmq::quorumInstantSendManager.get());
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
*
|
||||
* Please note, that members here should not be re-ordered, because initialization
|
||||
* some of them requires other member initialized.
|
||||
* For example, constructor `quorumManager` requires `bls_worker`.
|
||||
* For example, constructor `qman` requires `bls_worker`.
|
||||
*
|
||||
* Some objects are still global variables and their de-globalization is not trivial
|
||||
* at this point. LLMQContext keeps just a pointer to them and doesn't own these objects,
|
||||
@ -64,7 +64,7 @@ public:
|
||||
const std::unique_ptr<llmq::CDKGDebugManager> dkg_debugman;
|
||||
const std::unique_ptr<llmq::CQuorumBlockProcessor> quorum_block_processor;
|
||||
const std::unique_ptr<llmq::CDKGSessionManager> qdkgsman;
|
||||
llmq::CQuorumManager* const qman;
|
||||
const std::unique_ptr<llmq::CQuorumManager> qman;
|
||||
const std::unique_ptr<llmq::CSigningManager> sigman;
|
||||
const std::unique_ptr<llmq::CSigSharesManager> shareman;
|
||||
llmq::CChainLocksHandler* const clhandler;
|
||||
|
@ -33,8 +33,6 @@ namespace llmq
|
||||
static const std::string DB_QUORUM_SK_SHARE = "q_Qsk";
|
||||
static const std::string DB_QUORUM_QUORUM_VVEC = "q_Qqvvec";
|
||||
|
||||
std::unique_ptr<CQuorumManager> quorumManager;
|
||||
|
||||
RecursiveMutex cs_data_requests;
|
||||
static std::unordered_map<CQuorumDataRequestKey, CQuorumDataRequest, StaticSaltedHasher> mapQuorumDataRequests GUARDED_BY(cs_data_requests);
|
||||
|
||||
|
@ -289,8 +289,6 @@ private:
|
||||
void StartCleanupOldQuorumDataThread(const CBlockIndex* pIndex) const;
|
||||
};
|
||||
|
||||
extern std::unique_ptr<CQuorumManager> quorumManager;
|
||||
|
||||
// when selecting a quorum for signing and verification, we use CQuorumManager::SelectQuorum with this offset as
|
||||
// starting height for scanning. This is because otherwise the resulting signatures would not be verifiable by nodes
|
||||
// which are not 100% at the chain tip.
|
||||
|
@ -119,7 +119,7 @@ void DashTestSetup(NodeContext& node, const CChainParams& chainparams)
|
||||
#endif // ENABLE_WALLET
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainstate, *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman, *node.mempool,
|
||||
/* mn_activeman = */ nullptr, *node.mn_sync, node.peerman, /* unit_tests = */ true, /* wipe = */ false);
|
||||
Assert(node.mnhf_manager)->ConnectManagers(node.llmq_ctx->qman);
|
||||
Assert(node.mnhf_manager)->ConnectManagers(node.llmq_ctx->qman.get());
|
||||
node.chain_helper = std::make_unique<CChainstateHelper>(*node.cpoolman, *node.dmnman, *node.mnhf_manager, *node.govman, *(node.llmq_ctx->quorum_block_processor),
|
||||
chainparams.GetConsensus(), *node.mn_sync, *node.sporkman, *(node.llmq_ctx->clhandler), *(node.llmq_ctx->qman));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user