// Copyright (c) 2018-2021 The Dash Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include #include #include #include #include #include #include #include namespace llmq { CBLSWorker* blsWorker; CDBWrapper* llmqDb; void InitLLMQSystem(CEvoDB& evoDb, bool unitTests, bool fWipe) { llmqDb = new CDBWrapper(unitTests ? "" : (GetDataDir() / "llmq"), 8 << 20, unitTests, fWipe); blsWorker = new CBLSWorker(); quorumDKGDebugManager = new CDKGDebugManager(); quorumBlockProcessor = new CQuorumBlockProcessor(evoDb); quorumDKGSessionManager = new CDKGSessionManager(*llmqDb, *blsWorker); quorumManager = new CQuorumManager(evoDb, *blsWorker, *quorumDKGSessionManager); quorumSigSharesManager = new CSigSharesManager(); quorumSigningManager = new CSigningManager(*llmqDb, unitTests); chainLocksHandler = new CChainLocksHandler(); quorumInstantSendManager = new CInstantSendManager(*llmqDb); } void DestroyLLMQSystem() { delete quorumInstantSendManager; quorumInstantSendManager = nullptr; delete chainLocksHandler; chainLocksHandler = nullptr; delete quorumSigningManager; quorumSigningManager = nullptr; delete quorumSigSharesManager; quorumSigSharesManager = nullptr; delete quorumManager; quorumManager = nullptr; delete quorumDKGSessionManager; quorumDKGSessionManager = nullptr; delete quorumBlockProcessor; quorumBlockProcessor = nullptr; delete quorumDKGDebugManager; quorumDKGDebugManager = nullptr; delete blsWorker; blsWorker = nullptr; delete llmqDb; llmqDb = nullptr; LOCK(cs_llmq_vbc); llmq_versionbitscache.Clear(); } void StartLLMQSystem() { if (blsWorker) { blsWorker->Start(); } if (quorumDKGSessionManager) { quorumDKGSessionManager->StartThreads(); } if (quorumManager) { quorumManager->Start(); } if (quorumSigSharesManager) { quorumSigSharesManager->RegisterAsRecoveredSigsListener(); quorumSigSharesManager->StartWorkerThread(); } if (chainLocksHandler) { chainLocksHandler->Start(); } if (quorumInstantSendManager) { quorumInstantSendManager->Start(); } } void StopLLMQSystem() { if (quorumInstantSendManager) { quorumInstantSendManager->Stop(); } if (chainLocksHandler) { chainLocksHandler->Stop(); } if (quorumSigSharesManager) { quorumSigSharesManager->StopWorkerThread(); quorumSigSharesManager->UnregisterAsRecoveredSigsListener(); } if (quorumManager) { quorumManager->Stop(); } if (quorumDKGSessionManager) { quorumDKGSessionManager->StopThreads(); } if (blsWorker) { blsWorker->Stop(); } } void InterruptLLMQSystem() { if (quorumSigSharesManager) { quorumSigSharesManager->InterruptWorkerThread(); } if (quorumInstantSendManager) { quorumInstantSendManager->InterruptWorkerThread(); } } } // namespace llmq