2019-01-29 15:53:14 +01:00
|
|
|
// Copyright (c) 2018-2019 The Dash Core developers
|
2018-11-23 15:42:09 +01:00
|
|
|
// 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"
|
|
|
|
|
2019-01-08 09:13:56 +01:00
|
|
|
#include "quorums.h"
|
2018-11-23 15:42:09 +01:00
|
|
|
#include "quorums_blockprocessor.h"
|
|
|
|
#include "quorums_commitment.h"
|
2019-01-22 14:20:32 +01:00
|
|
|
#include "quorums_chainlocks.h"
|
2019-01-08 09:55:19 +01:00
|
|
|
#include "quorums_debug.h"
|
2018-05-24 16:14:55 +02:00
|
|
|
#include "quorums_dkgsessionmgr.h"
|
2018-09-21 16:01:04 +02:00
|
|
|
#include "quorums_instantsend.h"
|
2019-01-15 15:35:26 +01:00
|
|
|
#include "quorums_signing.h"
|
2019-01-17 16:42:03 +01:00
|
|
|
#include "quorums_signing_shares.h"
|
2018-11-23 15:42:09 +01:00
|
|
|
|
2019-03-08 17:28:08 +01:00
|
|
|
#include "dbwrapper.h"
|
2018-12-03 14:07:21 +01:00
|
|
|
#include "scheduler.h"
|
|
|
|
|
2018-11-23 15:42:09 +01:00
|
|
|
namespace llmq
|
|
|
|
{
|
|
|
|
|
2018-05-24 16:14:55 +02:00
|
|
|
static CBLSWorker blsWorker;
|
|
|
|
|
2019-03-08 17:28:08 +01:00
|
|
|
CDBWrapper* llmqDb;
|
|
|
|
|
2019-01-15 15:35:26 +01:00
|
|
|
void InitLLMQSystem(CEvoDB& evoDb, CScheduler* scheduler, bool unitTests)
|
2018-11-23 15:42:09 +01:00
|
|
|
{
|
2019-03-08 17:28:08 +01:00
|
|
|
llmqDb = new CDBWrapper(unitTests ? "" : (GetDataDir() / "llmq"), 1 << 20, unitTests);
|
|
|
|
|
2019-01-08 09:55:19 +01:00
|
|
|
quorumDKGDebugManager = new CDKGDebugManager(scheduler);
|
2018-11-23 15:42:09 +01:00
|
|
|
quorumBlockProcessor = new CQuorumBlockProcessor(evoDb);
|
2019-03-08 17:29:14 +01:00
|
|
|
quorumDKGSessionManager = new CDKGSessionManager(*llmqDb, blsWorker);
|
2019-01-08 09:13:56 +01:00
|
|
|
quorumManager = new CQuorumManager(evoDb, blsWorker, *quorumDKGSessionManager);
|
2019-01-17 16:42:03 +01:00
|
|
|
quorumSigSharesManager = new CSigSharesManager();
|
2019-03-08 17:30:34 +01:00
|
|
|
quorumSigningManager = new CSigningManager(*llmqDb, unitTests);
|
2019-01-22 14:20:32 +01:00
|
|
|
chainLocksHandler = new CChainLocksHandler(scheduler);
|
2018-09-21 16:01:04 +02:00
|
|
|
quorumInstantSendManager = new CInstantSendManager(scheduler);
|
2018-11-23 15:42:09 +01:00
|
|
|
}
|
|
|
|
|
2019-02-15 15:11:50 +01:00
|
|
|
void DestroyLLMQSystem()
|
|
|
|
{
|
2018-09-21 16:01:04 +02:00
|
|
|
delete quorumInstantSendManager;
|
|
|
|
quorumInstantSendManager = nullptr;
|
2019-01-22 14:20:32 +01:00
|
|
|
delete chainLocksHandler;
|
|
|
|
chainLocksHandler = nullptr;
|
2019-01-15 15:35:26 +01:00
|
|
|
delete quorumSigningManager;
|
|
|
|
quorumSigningManager = nullptr;
|
2019-01-17 16:42:03 +01:00
|
|
|
delete quorumSigSharesManager;
|
|
|
|
quorumSigSharesManager = nullptr;
|
2019-01-08 09:13:56 +01:00
|
|
|
delete quorumManager;
|
|
|
|
quorumManager = NULL;
|
2018-05-24 16:14:55 +02:00
|
|
|
delete quorumDKGSessionManager;
|
|
|
|
quorumDKGSessionManager = NULL;
|
2018-11-23 15:42:09 +01:00
|
|
|
delete quorumBlockProcessor;
|
|
|
|
quorumBlockProcessor = nullptr;
|
2019-01-08 09:55:19 +01:00
|
|
|
delete quorumDKGDebugManager;
|
|
|
|
quorumDKGDebugManager = nullptr;
|
2019-03-08 17:28:08 +01:00
|
|
|
delete llmqDb;
|
|
|
|
llmqDb = nullptr;
|
2018-11-23 15:42:09 +01:00
|
|
|
}
|
|
|
|
|
2019-02-17 12:39:43 +01:00
|
|
|
void StartLLMQSystem()
|
|
|
|
{
|
|
|
|
if (quorumDKGDebugManager) {
|
|
|
|
quorumDKGDebugManager->StartScheduler();
|
|
|
|
}
|
|
|
|
if (quorumDKGSessionManager) {
|
|
|
|
quorumDKGSessionManager->StartMessageHandlerPool();
|
|
|
|
}
|
|
|
|
if (quorumSigSharesManager) {
|
2019-02-27 14:10:12 +01:00
|
|
|
quorumSigSharesManager->RegisterAsRecoveredSigsListener();
|
2019-02-17 12:39:43 +01:00
|
|
|
quorumSigSharesManager->StartWorkerThread();
|
|
|
|
}
|
|
|
|
if (chainLocksHandler) {
|
2019-02-28 15:02:20 +01:00
|
|
|
chainLocksHandler->Start();
|
2019-02-17 12:39:43 +01:00
|
|
|
}
|
2018-09-21 16:01:04 +02:00
|
|
|
if (quorumInstantSendManager) {
|
|
|
|
quorumInstantSendManager->RegisterAsRecoveredSigsListener();
|
|
|
|
}
|
2019-02-17 12:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void StopLLMQSystem()
|
|
|
|
{
|
2018-09-21 16:01:04 +02:00
|
|
|
if (quorumInstantSendManager) {
|
|
|
|
quorumInstantSendManager->UnregisterAsRecoveredSigsListener();
|
|
|
|
}
|
2019-02-17 12:39:43 +01:00
|
|
|
if (chainLocksHandler) {
|
2019-02-28 15:02:20 +01:00
|
|
|
chainLocksHandler->Stop();
|
2019-02-17 12:39:43 +01:00
|
|
|
}
|
|
|
|
if (quorumSigSharesManager) {
|
|
|
|
quorumSigSharesManager->StopWorkerThread();
|
2019-02-27 14:10:12 +01:00
|
|
|
quorumSigSharesManager->UnregisterAsRecoveredSigsListener();
|
2019-02-17 12:39:43 +01:00
|
|
|
}
|
|
|
|
if (quorumDKGSessionManager) {
|
|
|
|
quorumDKGSessionManager->StopMessageHandlerPool();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterruptLLMQSystem()
|
|
|
|
{
|
|
|
|
if (quorumSigSharesManager) {
|
|
|
|
quorumSigSharesManager->InterruptWorkerThread();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-23 15:42:09 +01:00
|
|
|
}
|