61e10f6512
Instead of creating its own CDBWrapper internally.
108 lines
3.0 KiB
C++
108 lines
3.0 KiB
C++
// Copyright (c) 2018-2019 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 "quorums_init.h"
|
|
|
|
#include "quorums.h"
|
|
#include "quorums_blockprocessor.h"
|
|
#include "quorums_commitment.h"
|
|
#include "quorums_chainlocks.h"
|
|
#include "quorums_debug.h"
|
|
#include "quorums_dkgsessionmgr.h"
|
|
#include "quorums_instantsend.h"
|
|
#include "quorums_signing.h"
|
|
#include "quorums_signing_shares.h"
|
|
|
|
#include "dbwrapper.h"
|
|
#include "scheduler.h"
|
|
|
|
namespace llmq
|
|
{
|
|
|
|
static CBLSWorker blsWorker;
|
|
|
|
CDBWrapper* llmqDb;
|
|
|
|
void InitLLMQSystem(CEvoDB& evoDb, CScheduler* scheduler, bool unitTests)
|
|
{
|
|
llmqDb = new CDBWrapper(unitTests ? "" : (GetDataDir() / "llmq"), 1 << 20, unitTests);
|
|
|
|
quorumDKGDebugManager = new CDKGDebugManager(scheduler);
|
|
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(scheduler);
|
|
quorumInstantSendManager = new CInstantSendManager(scheduler);
|
|
}
|
|
|
|
void DestroyLLMQSystem()
|
|
{
|
|
delete quorumInstantSendManager;
|
|
quorumInstantSendManager = nullptr;
|
|
delete chainLocksHandler;
|
|
chainLocksHandler = nullptr;
|
|
delete quorumSigningManager;
|
|
quorumSigningManager = nullptr;
|
|
delete quorumSigSharesManager;
|
|
quorumSigSharesManager = nullptr;
|
|
delete quorumManager;
|
|
quorumManager = NULL;
|
|
delete quorumDKGSessionManager;
|
|
quorumDKGSessionManager = NULL;
|
|
delete quorumBlockProcessor;
|
|
quorumBlockProcessor = nullptr;
|
|
delete quorumDKGDebugManager;
|
|
quorumDKGDebugManager = nullptr;
|
|
delete llmqDb;
|
|
llmqDb = nullptr;
|
|
}
|
|
|
|
void StartLLMQSystem()
|
|
{
|
|
if (quorumDKGDebugManager) {
|
|
quorumDKGDebugManager->StartScheduler();
|
|
}
|
|
if (quorumDKGSessionManager) {
|
|
quorumDKGSessionManager->StartMessageHandlerPool();
|
|
}
|
|
if (quorumSigSharesManager) {
|
|
quorumSigSharesManager->RegisterAsRecoveredSigsListener();
|
|
quorumSigSharesManager->StartWorkerThread();
|
|
}
|
|
if (chainLocksHandler) {
|
|
chainLocksHandler->Start();
|
|
}
|
|
if (quorumInstantSendManager) {
|
|
quorumInstantSendManager->RegisterAsRecoveredSigsListener();
|
|
}
|
|
}
|
|
|
|
void StopLLMQSystem()
|
|
{
|
|
if (quorumInstantSendManager) {
|
|
quorumInstantSendManager->UnregisterAsRecoveredSigsListener();
|
|
}
|
|
if (chainLocksHandler) {
|
|
chainLocksHandler->Stop();
|
|
}
|
|
if (quorumSigSharesManager) {
|
|
quorumSigSharesManager->StopWorkerThread();
|
|
quorumSigSharesManager->UnregisterAsRecoveredSigsListener();
|
|
}
|
|
if (quorumDKGSessionManager) {
|
|
quorumDKGSessionManager->StopMessageHandlerPool();
|
|
}
|
|
}
|
|
|
|
void InterruptLLMQSystem()
|
|
{
|
|
if (quorumSigSharesManager) {
|
|
quorumSigSharesManager->InterruptWorkerThread();
|
|
}
|
|
}
|
|
|
|
}
|