Skip to content

Commit

Permalink
refactor: using reference instead reference to unique_ptr with object (
Browse files Browse the repository at this point in the history
…#5381)

## Issue being fixed or feature implemented
Many objects created and functions called by passing `const
std::unique_ptr<Obj>& obj` instead directly passing `Obj& obj`

In some cases it is indeed needed, but in most cases it is just extra
complexity that is better to avoid.

Motivation:
- providing reference to object instead `unique_ptr` is giving warranty
that there's no `nullptr` and no need to keep it in mind
- value inside unique_ptr by reference can be changed externally and
instead `nullptr` it can turn to real object later (or in opposite)
 - code is shorter but cleaner

Based on that this refactoring is useful as it reduces mental load when
reading or writing code.
`std::unique` should be used ONLY for owning object, but not for passing
it everywhere.

## What was done?
Replaced most of usages `std::unique_ptr<Obj>& obj` to `Obj& obj`.
Btw, in several cases implementation assumes that object can be nullptr
and replacement to reference is not possible.
Even using raw pointer is not possible, because the empty
std::unique_ptr can be initialized later somewhere in code.
For example, in `src/init.cpp` there's called `PeerManager::make` and
pass unique_ptr to the `node.llmq_ctx` that would be initialized way
later.
That is out of scope this PR.
List of cases, where reference to `std::unique_ptr` stayed as they are:
- `std::unique_ptr<LLMQContext>& llmq_ctx` in `PeerManagerImpl`,
`PeerManager` and `CDSNotificationInterface`
- `std::unique_ptr<CDeterministicMNManager>& dmnman` in
`CDSNotificationInterface`

Also `CChainState` have 3 references to `unique_ptr` that can't be
replaced too:
 - `std::unique_ptr<llmq::CChainLocksHandler>& m_clhandler;`
 - `std::unique_ptr<llmq::CInstantSendManager>& m_isman;`
- `std::unique_ptr<llmq::CQuorumBlockProcessor>&
m_quorum_block_processor;`


## How Has This Been Tested?
Run unit/functional tests.

## Breaking Changes
No breaking changes, all of these changes - are internal APIs for Dash
Core developers only.

## Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added or updated relevant unit/integration/functional/e2e
tests
- [x] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone

---------

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
  • Loading branch information
knst and UdjinM6 authored Jun 4, 2023
1 parent 89fcecb commit 86dc99f
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 109 deletions.
20 changes: 9 additions & 11 deletions src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void CCoinJoinClientQueueManager::ProcessMessage(const CNode& peer, PeerManager&
{
if (fMasternodeMode) return;
if (!CCoinJoinClientOptions::IsEnabled()) return;
if (!m_mn_sync->IsBlockchainSynced()) return;
if (!m_mn_sync.IsBlockchainSynced()) return;

if (!CheckDiskSpace(GetDataDir())) {
LogPrint(BCLog::COINJOIN, "CCoinJoinClientQueueManager::ProcessMessage -- Not enough disk space, disabling CoinJoin.\n");
Expand Down Expand Up @@ -134,7 +134,7 @@ void CCoinJoinClientManager::ProcessMessage(CNode& peer, PeerManager& peerman, C
{
if (fMasternodeMode) return;
if (!CCoinJoinClientOptions::IsEnabled()) return;
if (!m_mn_sync->IsBlockchainSynced()) return;
if (!m_mn_sync.IsBlockchainSynced()) return;

if (!CheckDiskSpace(GetDataDir())) {
ResetPool();
Expand All @@ -158,7 +158,7 @@ void CCoinJoinClientSession::ProcessMessage(CNode& peer, PeerManager& peerman, C
{
if (fMasternodeMode) return;
if (!CCoinJoinClientOptions::IsEnabled()) return;
if (!m_mn_sync->IsBlockchainSynced()) return;
if (!m_mn_sync.IsBlockchainSynced()) return;

if (msg_type == NetMsgType::DSSTATUSUPDATE) {
if (!mixingMasternode) return;
Expand Down Expand Up @@ -289,7 +289,7 @@ bilingual_str CCoinJoinClientSession::GetStatus(bool fWaitForBlock) const
nStatusMessageProgress += 10;
std::string strSuffix;

if (fWaitForBlock || !m_mn_sync->IsBlockchainSynced()) {
if (fWaitForBlock || !m_mn_sync.IsBlockchainSynced()) {
return strAutoDenomResult;
}

Expand Down Expand Up @@ -691,7 +691,7 @@ void CCoinJoinClientManager::UpdatedSuccessBlock()

bool CCoinJoinClientManager::WaitForAnotherBlock() const
{
if (!m_mn_sync->IsBlockchainSynced()) return true;
if (!m_mn_sync.IsBlockchainSynced()) return true;

if (CCoinJoinClientOptions::IsMultiSessionEnabled()) return false;

Expand Down Expand Up @@ -773,7 +773,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, CBlockPo
if (fMasternodeMode) return false; // no client-side mixing on masternodes
if (nState != POOL_STATE_IDLE) return false;

if (!m_mn_sync->IsBlockchainSynced()) {
if (!m_mn_sync.IsBlockchainSynced()) {
strAutoDenomResult = _("Can't mix while sync in progress.");
return false;
}
Expand Down Expand Up @@ -953,7 +953,7 @@ bool CCoinJoinClientManager::DoAutomaticDenominating(CConnman& connman, CBlockPo
if (fMasternodeMode) return false; // no client-side mixing on masternodes
if (!CCoinJoinClientOptions::IsEnabled() || !IsMixing()) return false;

if (!m_mn_sync->IsBlockchainSynced()) {
if (!m_mn_sync.IsBlockchainSynced()) {
strAutoDenomResult = _("Can't mix while sync in progress.");
return false;
}
Expand Down Expand Up @@ -1819,21 +1819,19 @@ void CCoinJoinClientManager::UpdatedBlockTip(const CBlockIndex* pindex)
void CCoinJoinClientQueueManager::DoMaintenance()
{
if (!CCoinJoinClientOptions::IsEnabled()) return;
if (m_mn_sync == nullptr) return;
if (fMasternodeMode) return; // no client-side mixing on masternodes

if (!m_mn_sync->IsBlockchainSynced() || ShutdownRequested()) return;
if (!m_mn_sync.IsBlockchainSynced() || ShutdownRequested()) return;

CheckQueue();
}

void CCoinJoinClientManager::DoMaintenance(CConnman& connman, CBlockPolicyEstimator& fee_estimator, CTxMemPool& mempool)
{
if (!CCoinJoinClientOptions::IsEnabled()) return;
if (m_mn_sync == nullptr) return;
if (fMasternodeMode) return; // no client-side mixing on masternodes

if (!m_mn_sync->IsBlockchainSynced() || ShutdownRequested()) return;
if (!m_mn_sync.IsBlockchainSynced() || ShutdownRequested()) return;

static int nTick = 0;
static int nDoAutoNextRun = nTick + COINJOIN_AUTO_TIMEOUT_MIN;
Expand Down
12 changes: 6 additions & 6 deletions src/coinjoin/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CPendingDsaRequest
class CCoinJoinClientSession : public CCoinJoinBaseSession
{
private:
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
const CMasternodeSync& m_mn_sync;

std::vector<COutPoint> vecOutPointLocked;

Expand Down Expand Up @@ -124,7 +124,7 @@ class CCoinJoinClientSession : public CCoinJoinBaseSession
void SetNull() EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin);

public:
explicit CCoinJoinClientSession(CWallet& pwallet, const std::unique_ptr<CMasternodeSync>& mn_sync) :
explicit CCoinJoinClientSession(CWallet& pwallet, const CMasternodeSync& mn_sync) :
m_mn_sync(mn_sync), mixingWallet(pwallet)
{
}
Expand Down Expand Up @@ -158,10 +158,10 @@ class CCoinJoinClientQueueManager : public CCoinJoinBaseManager
{
private:
CConnman& connman;
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
const CMasternodeSync& m_mn_sync;

public:
explicit CCoinJoinClientQueueManager(CConnman& _connman, const std::unique_ptr<CMasternodeSync>& mn_sync) :
explicit CCoinJoinClientQueueManager(CConnman& _connman, const CMasternodeSync& mn_sync) :
connman(_connman), m_mn_sync(mn_sync) {};

void ProcessMessage(const CNode& peer, PeerManager& peerman, std::string_view msg_type, CDataStream& vRecv) LOCKS_EXCLUDED(cs_vecqueue);
Expand All @@ -177,7 +177,7 @@ class CCoinJoinClientManager
// Keep track of the used Masternodes
std::vector<COutPoint> vecMasternodesUsed;

const std::unique_ptr<CMasternodeSync>& m_mn_sync;
const CMasternodeSync& m_mn_sync;

mutable Mutex cs_deqsessions;
// TODO: or map<denom, CCoinJoinClientSession> ??
Expand Down Expand Up @@ -207,7 +207,7 @@ class CCoinJoinClientManager
CCoinJoinClientManager(CCoinJoinClientManager const&) = delete;
CCoinJoinClientManager& operator=(CCoinJoinClientManager const&) = delete;

explicit CCoinJoinClientManager(CWallet& wallet, const std::unique_ptr<CMasternodeSync>& mn_sync) :
explicit CCoinJoinClientManager(CWallet& wallet, const CMasternodeSync& mn_sync) :
m_mn_sync(mn_sync), mixingWallet(wallet) {}

void ProcessMessage(CNode& peer, PeerManager& peerman, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv) LOCKS_EXCLUDED(cs_deqsessions);
Expand Down
8 changes: 4 additions & 4 deletions src/coinjoin/coinjoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,16 @@ void CCoinJoin::CheckDSTXes(const CBlockIndex* pindex, const llmq::CChainLocksHa
LogPrint(BCLog::COINJOIN, "CCoinJoin::CheckDSTXes -- mapDSTX.size()=%llu\n", mapDSTX.size());
}

void CCoinJoin::UpdatedBlockTip(const CBlockIndex* pindex, const llmq::CChainLocksHandler& clhandler, const std::unique_ptr<CMasternodeSync>& mn_sync)
void CCoinJoin::UpdatedBlockTip(const CBlockIndex* pindex, const llmq::CChainLocksHandler& clhandler, const CMasternodeSync& mn_sync)
{
if (pindex && mn_sync->IsBlockchainSynced()) {
if (pindex && mn_sync.IsBlockchainSynced()) {
CheckDSTXes(pindex, clhandler);
}
}

void CCoinJoin::NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLocksHandler& clhandler, const std::unique_ptr<CMasternodeSync>& mn_sync)
void CCoinJoin::NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLocksHandler& clhandler, const CMasternodeSync& mn_sync)
{
if (pindex && mn_sync->IsBlockchainSynced()) {
if (pindex && mn_sync.IsBlockchainSynced()) {
CheckDSTXes(pindex, clhandler);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/coinjoin/coinjoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ class CCoinJoin
static void AddDSTX(const CCoinJoinBroadcastTx& dstx) LOCKS_EXCLUDED(cs_mapdstx);
static CCoinJoinBroadcastTx GetDSTX(const uint256& hash) LOCKS_EXCLUDED(cs_mapdstx);

static void UpdatedBlockTip(const CBlockIndex* pindex, const llmq::CChainLocksHandler& clhandler, const std::unique_ptr<CMasternodeSync>& mn_sync);
static void NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLocksHandler& clhandler, const std::unique_ptr<CMasternodeSync>& mn_sync);
static void UpdatedBlockTip(const CBlockIndex* pindex, const llmq::CChainLocksHandler& clhandler, const CMasternodeSync& mn_sync);
static void NotifyChainLock(const CBlockIndex* pindex, const llmq::CChainLocksHandler& clhandler, const CMasternodeSync& mn_sync);

static void TransactionAddedToMempool(const CTransactionRef& tx) LOCKS_EXCLUDED(cs_mapdstx);
static void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex) LOCKS_EXCLUDED(cs_mapdstx);
Expand Down
4 changes: 2 additions & 2 deletions src/coinjoin/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ constexpr static CAmount DEFAULT_MAX_RAW_TX_FEE{COIN / 10};
void CCoinJoinServer::ProcessMessage(CNode& peer, PeerManager& peerman, std::string_view msg_type, CDataStream& vRecv)
{
if (!fMasternodeMode) return;
if (!m_mn_sync->IsBlockchainSynced()) return;
if (!m_mn_sync.IsBlockchainSynced()) return;

if (msg_type == NetMsgType::DSACCEPT) {
ProcessDSACCEPT(peer, vRecv);
Expand Down Expand Up @@ -889,7 +889,7 @@ void CCoinJoinServer::SetState(PoolState nStateNew)
void CCoinJoinServer::DoMaintenance() const
{
if (!fMasternodeMode) return; // only run on masternodes
if (m_mn_sync == nullptr || !m_mn_sync->IsBlockchainSynced()) return;
if (!m_mn_sync.IsBlockchainSynced()) return;
if (ShutdownRequested()) return;

if (!coinJoinServer) return;
Expand Down
4 changes: 2 additions & 2 deletions src/coinjoin/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CCoinJoinServer : public CCoinJoinBaseSession, public CCoinJoinBaseManager
private:
CTxMemPool& mempool;
CConnman& connman;
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
const CMasternodeSync& m_mn_sync;

// Mixing uses collateral transactions to trust parties entering the pool
// to behave honestly. If they don't it takes their money.
Expand Down Expand Up @@ -79,7 +79,7 @@ class CCoinJoinServer : public CCoinJoinBaseSession, public CCoinJoinBaseManager
void SetNull() EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin);

public:
explicit CCoinJoinServer(CTxMemPool& mempool, CConnman& _connman, const std::unique_ptr<CMasternodeSync>& mn_sync) :
explicit CCoinJoinServer(CTxMemPool& mempool, CConnman& _connman, const CMasternodeSync& mn_sync) :
mempool(mempool),
connman(_connman),
m_mn_sync(mn_sync),
Expand Down
16 changes: 7 additions & 9 deletions src/dsnotificationinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include <llmq/quorums.h>

CDSNotificationInterface::CDSNotificationInterface(CConnman& _connman,
std::unique_ptr<CMasternodeSync>& _mn_sync, std::unique_ptr<CDeterministicMNManager>& _dmnman,
std::unique_ptr<CGovernanceManager>& _govman, std::unique_ptr<LLMQContext>& _llmq_ctx
CMasternodeSync& _mn_sync, const std::unique_ptr<CDeterministicMNManager>& _dmnman,
CGovernanceManager& _govman, const std::unique_ptr<LLMQContext>& _llmq_ctx
) : connman(_connman), m_mn_sync(_mn_sync), dmnman(_dmnman), govman(_govman), llmq_ctx(_llmq_ctx) {}

void CDSNotificationInterface::InitializeCurrentBlockTip()
Expand All @@ -35,14 +35,12 @@ void CDSNotificationInterface::InitializeCurrentBlockTip()
void CDSNotificationInterface::AcceptedBlockHeader(const CBlockIndex *pindexNew)
{
llmq_ctx->clhandler->AcceptedBlockHeader(pindexNew);
if (m_mn_sync != nullptr) {
m_mn_sync->AcceptedBlockHeader(pindexNew);
}
m_mn_sync.AcceptedBlockHeader(pindexNew);
}

void CDSNotificationInterface::NotifyHeaderTip(const CBlockIndex *pindexNew, bool fInitialDownload)
{
m_mn_sync->NotifyHeaderTip(pindexNew, fInitialDownload);
m_mn_sync.NotifyHeaderTip(pindexNew, fInitialDownload);
}

void CDSNotificationInterface::SynchronousUpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload)
Expand All @@ -58,7 +56,7 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
if (pindexNew == pindexFork) // blocks were disconnected without any new ones
return;

m_mn_sync->UpdatedBlockTip(pindexNew, fInitialDownload);
m_mn_sync.UpdatedBlockTip(pindexNew, fInitialDownload);

// Update global DIP0001 activation status
fDIP0001ActiveAtTip = pindexNew->nHeight >= Params().GetConsensus().DIP0001Height;
Expand All @@ -79,7 +77,7 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
llmq_ctx->qman->UpdatedBlockTip(pindexNew, fInitialDownload);
llmq_ctx->qdkgsman->UpdatedBlockTip(pindexNew, fInitialDownload);

if (!fDisableGovernance) govman->UpdatedBlockTip(pindexNew, connman);
if (!fDisableGovernance) govman.UpdatedBlockTip(pindexNew, connman);
}

void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx, int64_t nAcceptTime)
Expand Down Expand Up @@ -119,7 +117,7 @@ void CDSNotificationInterface::BlockDisconnected(const std::shared_ptr<const CBl
void CDSNotificationInterface::NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman)
{
CMNAuth::NotifyMasternodeListChanged(undo, oldMNList, diff, connman);
govman->UpdateCachesAndClean();
govman.UpdateCachesAndClean();
}

void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig)
Expand Down
12 changes: 6 additions & 6 deletions src/dsnotificationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class CDSNotificationInterface : public CValidationInterface
{
public:
explicit CDSNotificationInterface(CConnman& _connman,
std::unique_ptr<CMasternodeSync>& _mn_sync, std::unique_ptr<CDeterministicMNManager>& _dmnman,
std::unique_ptr<CGovernanceManager>& _govman, std::unique_ptr<LLMQContext>& _llmq_ctx);
CMasternodeSync& _mn_sync, const std::unique_ptr<CDeterministicMNManager>& _dmnman,
CGovernanceManager& _govman, const std::unique_ptr<LLMQContext>& _llmq_ctx);
virtual ~CDSNotificationInterface() = default;

// a small helper to initialize current block height in sub-modules on startup
Expand All @@ -40,11 +40,11 @@ class CDSNotificationInterface : public CValidationInterface
private:
CConnman& connman;

std::unique_ptr<CMasternodeSync>& m_mn_sync;
std::unique_ptr<CDeterministicMNManager>& dmnman;
std::unique_ptr<CGovernanceManager>& govman;
CMasternodeSync& m_mn_sync;
const std::unique_ptr<CDeterministicMNManager>& dmnman;
CGovernanceManager& govman;

std::unique_ptr<LLMQContext>& llmq_ctx;
const std::unique_ptr<LLMQContext>& llmq_ctx;
};

#endif // BITCOIN_DSNOTIFICATIONINTERFACE_H
10 changes: 6 additions & 4 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1945,8 +1945,10 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
}
#endif

assert(masternodeSync != nullptr);
assert(governance != nullptr);
pdsNotificationInterface = new CDSNotificationInterface(
*node.connman, ::masternodeSync, ::deterministicMNManager, ::governance, node.llmq_ctx
*node.connman, *::masternodeSync, ::deterministicMNManager, *::governance, node.llmq_ctx
);
RegisterValidationInterface(pdsNotificationInterface);

Expand Down Expand Up @@ -2021,7 +2023,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
LOCK(cs_main);
node.evodb.reset();
node.evodb = std::make_unique<CEvoDB>(nEvoDbCache, false, fReset || fReindexChainState);
chainman.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, node.evodb, *Assert(node.mempool));
chainman.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, *node.evodb, *Assert(node.mempool));
chainman.m_total_coinstip_cache = nCoinCacheUsage;
chainman.m_total_coinsdb_cache = nCoinDBCache;

Expand Down Expand Up @@ -2318,10 +2320,10 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc

// ********************************************************* Step 10a: Setup CoinJoin

::coinJoinServer = std::make_unique<CCoinJoinServer>(*node.mempool, *node.connman, ::masternodeSync);
::coinJoinServer = std::make_unique<CCoinJoinServer>(*node.mempool, *node.connman, *::masternodeSync);
#ifdef ENABLE_WALLET
if (!ignores_incoming_txs) {
::coinJoinClientQueueManager = std::make_unique<CCoinJoinClientQueueManager>(*node.connman, ::masternodeSync);
::coinJoinClientQueueManager = std::make_unique<CCoinJoinClientQueueManager>(*node.connman, *::masternodeSync);
}
#endif // ENABLE_WALLET

Expand Down
8 changes: 4 additions & 4 deletions src/llmq/chainlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::unique_ptr<CChainLocksHandler> chainLocksHandler;

CChainLocksHandler::CChainLocksHandler(CTxMemPool& _mempool, CConnman& _connman, CSporkManager& sporkManager,
CSigningManager& _sigman, CSigSharesManager& _shareman, CQuorumManager& _qman,
const std::unique_ptr<CMasternodeSync>& mn_sync,
CMasternodeSync& mn_sync,
const std::unique_ptr<PeerManager>& peerman) :
connman(_connman),
mempool(_mempool),
Expand Down Expand Up @@ -241,7 +241,7 @@ void CChainLocksHandler::TrySignChainTip()
return;
}

if (!m_mn_sync->IsBlockchainSynced()) {
if (!m_mn_sync.IsBlockchainSynced()) {
return;
}

Expand Down Expand Up @@ -361,7 +361,7 @@ void CChainLocksHandler::TransactionAddedToMempool(const CTransactionRef& tx, in

void CChainLocksHandler::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
{
if (!m_mn_sync->IsBlockchainSynced()) {
if (!m_mn_sync.IsBlockchainSynced()) {
return;
}

Expand Down Expand Up @@ -628,7 +628,7 @@ bool CChainLocksHandler::InternalHasConflictingChainLock(int nHeight, const uint

void CChainLocksHandler::Cleanup()
{
if (!m_mn_sync->IsBlockchainSynced()) {
if (!m_mn_sync.IsBlockchainSynced()) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/llmq/chainlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CChainLocksHandler : public CRecoveredSigsListener
CSigSharesManager& shareman;
CQuorumManager& qman;

const std::unique_ptr<CMasternodeSync>& m_mn_sync;
CMasternodeSync& m_mn_sync;
const std::unique_ptr<PeerManager>& m_peerman;

std::unique_ptr<CScheduler> scheduler;
Expand Down Expand Up @@ -86,7 +86,7 @@ class CChainLocksHandler : public CRecoveredSigsListener
public:
explicit CChainLocksHandler(CTxMemPool& _mempool, CConnman& _connman, CSporkManager& sporkManager,
CSigningManager& _sigman, CSigSharesManager& _shareman, CQuorumManager& _qman,
const std::unique_ptr<CMasternodeSync>& mn_sync,
CMasternodeSync& mn_sync,
const std::unique_ptr<PeerManager>& peerman);
~CChainLocksHandler();

Expand Down
4 changes: 2 additions & 2 deletions src/llmq/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void LLMQContext::Create(CEvoDB& evo_db, CTxMemPool& mempool, CConnman& connman,
llmq::quorumManager = std::make_unique<llmq::CQuorumManager>(evo_db, connman, *bls_worker, *llmq::quorumBlockProcessor, *qdkgsman, ::masternodeSync, peerman);
sigman = std::make_unique<llmq::CSigningManager>(connman, *llmq::quorumManager, peerman, unit_tests, wipe);
shareman = std::make_unique<llmq::CSigSharesManager>(connman, *llmq::quorumManager, *sigman, peerman);
llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(mempool, connman, sporkman, *sigman, *shareman, *llmq::quorumManager, ::masternodeSync, peerman);
llmq::quorumInstantSendManager = std::make_unique<llmq::CInstantSendManager>(mempool, connman, sporkman, *llmq::quorumManager, *sigman, *shareman, *llmq::chainLocksHandler, ::masternodeSync, peerman, unit_tests, wipe);
llmq::chainLocksHandler = std::make_unique<llmq::CChainLocksHandler>(mempool, connman, sporkman, *sigman, *shareman, *llmq::quorumManager, *::masternodeSync, peerman);
llmq::quorumInstantSendManager = std::make_unique<llmq::CInstantSendManager>(mempool, connman, sporkman, *llmq::quorumManager, *sigman, *shareman, *llmq::chainLocksHandler, *::masternodeSync, peerman, unit_tests, wipe);

// NOTE: we use this only to wipe the old db, do NOT use it for anything else
// TODO: remove it in some future version
Expand Down
Loading

0 comments on commit 86dc99f

Please sign in to comment.