refactor: using reference instead reference to unique_ptr with object (#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>
This commit is contained in:
Konstantin Akimov 2023-06-05 03:26:23 +07:00 committed by GitHub
parent 89fcecbe4b
commit 86dc99f10d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 111 additions and 109 deletions

View File

@ -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");
@ -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();
@ -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;
@ -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;
}
@ -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;
@ -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;
}
@ -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;
}
@ -1819,10 +1819,9 @@ 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();
}
@ -1830,10 +1829,9 @@ void CCoinJoinClientQueueManager::DoMaintenance()
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;

View File

@ -74,7 +74,7 @@ public:
class CCoinJoinClientSession : public CCoinJoinBaseSession
{
private:
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
const CMasternodeSync& m_mn_sync;
std::vector<COutPoint> vecOutPointLocked;
@ -124,7 +124,7 @@ private:
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)
{
}
@ -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);
@ -177,7 +177,7 @@ private:
// 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> ??
@ -207,7 +207,7 @@ public:
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);

View File

@ -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);
}
}

View File

@ -502,8 +502,8 @@ public:
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);

View File

@ -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);
@ -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;

View File

@ -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.
@ -79,7 +79,7 @@ private:
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),

View File

@ -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()
@ -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)
@ -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;
@ -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)
@ -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)

View File

@ -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
@ -40,11 +40,11 @@ protected:
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

View File

@ -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);
@ -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;
@ -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

View File

@ -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),
@ -241,7 +241,7 @@ void CChainLocksHandler::TrySignChainTip()
return;
}
if (!m_mn_sync->IsBlockchainSynced()) {
if (!m_mn_sync.IsBlockchainSynced()) {
return;
}
@ -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;
}
@ -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;
}

View File

@ -49,7 +49,7 @@ private:
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;
@ -86,7 +86,7 @@ private:
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();

View File

@ -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

View File

@ -480,7 +480,7 @@ void CInstantSendManager::Stop()
void CInstantSendManager::ProcessTx(const CTransaction& tx, bool fRetroactive, const Consensus::Params& params)
{
if (!fMasternodeMode || !IsInstantSendEnabled() || !m_mn_sync->IsBlockchainSynced()) {
if (!fMasternodeMode || !IsInstantSendEnabled() || !m_mn_sync.IsBlockchainSynced()) {
return;
}
@ -1138,7 +1138,7 @@ void CInstantSendManager::ProcessInstantSendLock(NodeId from, const uint256& has
void CInstantSendManager::TransactionAddedToMempool(const CTransactionRef& tx)
{
if (!IsInstantSendEnabled() || !m_mn_sync->IsBlockchainSynced() || tx->vin.empty()) {
if (!IsInstantSendEnabled() || !m_mn_sync.IsBlockchainSynced() || tx->vin.empty()) {
return;
}
@ -1191,7 +1191,7 @@ void CInstantSendManager::BlockConnected(const std::shared_ptr<const CBlock>& pb
return;
}
if (m_mn_sync->IsBlockchainSynced()) {
if (m_mn_sync.IsBlockchainSynced()) {
for (const auto& tx : pblock->vtx) {
if (tx->IsCoinBase() || tx->vin.empty()) {
// coinbase and TXs with no inputs can't be locked
@ -1738,7 +1738,7 @@ bool CInstantSendManager::IsInstantSendMempoolSigningEnabled() const
bool CInstantSendManager::RejectConflictingBlocks() const
{
if (m_mn_sync == nullptr || !m_mn_sync->IsBlockchainSynced()) {
if (!m_mn_sync.IsBlockchainSynced()) {
return false;
}
if (!spork_manager.IsSporkActive(SPORK_3_INSTANTSEND_BLOCK_FILTERING)) {

View File

@ -211,7 +211,7 @@ private:
CSigSharesManager& shareman;
CChainLocksHandler& clhandler;
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
const CMasternodeSync& m_mn_sync;
const std::unique_ptr<PeerManager>& m_peerman;
std::atomic<bool> fUpgradedDB{false};
@ -262,7 +262,7 @@ private:
public:
explicit CInstantSendManager(CTxMemPool& _mempool, CConnman& _connman, CSporkManager& sporkManager,
CQuorumManager& _qman, CSigningManager& _sigman, CSigSharesManager& _shareman,
CChainLocksHandler& _clhandler, const std::unique_ptr<CMasternodeSync>& mn_sync,
CChainLocksHandler& _clhandler, CMasternodeSync& mn_sync,
const std::unique_ptr<PeerManager>& peerman, bool unitTests, bool fWipe) :
db(unitTests, fWipe), connman(_connman), mempool(_mempool), spork_manager(sporkManager), qman(_qman), sigman(_sigman), shareman(_shareman),
clhandler(_clhandler), m_mn_sync(mn_sync), m_peerman(peerman)

View File

@ -216,7 +216,7 @@ class PeerManagerImpl final : public PeerManager
public:
PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman,
BanMan* banman, CScheduler &scheduler, ChainstateManager& chainman,
CTxMemPool& pool, std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs);
CTxMemPool& pool, const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs);
/** Overridden from CValidationInterface. */
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
@ -305,7 +305,7 @@ private:
CAddrMan& m_addrman;
ChainstateManager& m_chainman;
CTxMemPool& m_mempool;
std::unique_ptr<LLMQContext>& m_llmq_ctx;
const std::unique_ptr<LLMQContext>& m_llmq_ctx;
/** The height of the best chain */
std::atomic<int> m_best_height{-1};
@ -1463,14 +1463,14 @@ static bool BlockRequestAllowed(const CBlockIndex* pindex, const Consensus::Para
std::unique_ptr<PeerManager> PeerManager::make(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, BanMan* banman,
CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool,
std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs)
const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs)
{
return std::make_unique<PeerManagerImpl>(chainparams, connman, addrman, banman, scheduler, chainman, pool, llmq_ctx, ignore_incoming_txs);
}
PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, BanMan* banman,
CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool,
std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs)
const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs)
: m_chainparams(chainparams),
m_connman(connman),
m_addrman(addrman),

View File

@ -37,7 +37,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
public:
static std::unique_ptr<PeerManager> make(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman,
BanMan* banman, CScheduler &scheduler, ChainstateManager& chainman,
CTxMemPool& pool, std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs);
CTxMemPool& pool, const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs);
virtual ~PeerManager() { }
/** Get statistics from node state */

View File

@ -180,9 +180,9 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
::sporkManager = std::make_unique<CSporkManager>();
::governance = std::make_unique<CGovernanceManager>();
::masternodeSync = std::make_unique<CMasternodeSync>(*m_node.connman);
::coinJoinServer = std::make_unique<CCoinJoinServer>(*m_node.mempool, *m_node.connman, ::masternodeSync);
::coinJoinServer = std::make_unique<CCoinJoinServer>(*m_node.mempool, *m_node.connman, *::masternodeSync);
#ifdef ENABLE_WALLET
::coinJoinClientQueueManager = std::make_unique<CCoinJoinClientQueueManager>(*m_node.connman, ::masternodeSync);
::coinJoinClientQueueManager = std::make_unique<CCoinJoinClientQueueManager>(*m_node.connman, *::masternodeSync);
#endif // ENABLE_WALLET
deterministicMNManager.reset(new CDeterministicMNManager(*m_node.evodb, *m_node.connman));
@ -231,7 +231,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
// instead of unit tests, but for now we need these here.
RegisterAllCoreRPCCommands(tableRPC);
m_node.chainman->InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, *m_node.mempool);
m_node.chainman->InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, *m_node.evodb, *m_node.mempool);
::ChainstateActive().InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
assert(!::ChainstateActive().CanFlushToDisk());

View File

@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
return outp;
};
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool));
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, *m_node.evodb, mempool));
c1.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));

View File

@ -28,13 +28,14 @@ BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, ChainTestingSetup)
BOOST_AUTO_TEST_CASE(chainstatemanager)
{
ChainstateManager& manager = *m_node.chainman;
CTxMemPool &mempool = *m_node.mempool;
CTxMemPool& mempool = *m_node.mempool;
CEvoDB& evodb = *m_node.evodb;
std::vector<CChainState*> chainstates;
const CChainParams& chainparams = Params();
// Create a legacy (IBD) chainstate.
//
CChainState& c1 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool));
CChainState& c1 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, evodb, mempool));
chainstates.push_back(&c1);
c1.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@ -60,7 +61,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
// Create a snapshot-based chainstate.
//
CChainState& c2 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool, GetRandHash()));
CChainState& c2 = *WITH_LOCK(::cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, evodb, mempool, GetRandHash()));
chainstates.push_back(&c2);
c2.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@ -111,6 +112,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
{
ChainstateManager& manager = *m_node.chainman;
CTxMemPool& mempool = *m_node.mempool;
CEvoDB& evodb = *m_node.evodb;
size_t max_cache = 10000;
manager.m_total_coinsdb_cache = max_cache;
manager.m_total_coinstip_cache = max_cache;
@ -119,7 +121,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
// Create a legacy (IBD) chainstate.
//
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool));
CChainState& c1 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, evodb, mempool));
chainstates.push_back(&c1);
c1.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);
@ -137,7 +139,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
// Create a snapshot-based chainstate.
//
CChainState& c2 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool, GetRandHash()));
CChainState& c2 = *WITH_LOCK(cs_main, return &manager.InitializeChainstate(llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, evodb, mempool, GetRandHash()));
chainstates.push_back(&c2);
c2.InitCoinsDB(
/* cache_size_bytes */ 1 << 23, /* in_memory */ true, /* should_wipe */ false);

View File

@ -24,7 +24,7 @@ BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
{
CTxMemPool mempool;
BlockManager blockman{};
CChainState chainstate(blockman, llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, m_node.evodb, mempool);
CChainState chainstate(blockman, llmq::chainLocksHandler, llmq::quorumInstantSendManager, llmq::quorumBlockProcessor, *m_node.evodb, mempool);
chainstate.InitCoinsDB(/*cache_size_bytes*/ 1 << 10, /*in_memory*/ true, /*should_wipe*/ false);
WITH_LOCK(::cs_main, chainstate.InitCoinsCache(1 << 10));
CTxMemPool tx_pool{};

View File

@ -1296,10 +1296,10 @@ void CoinsViews::InitCache()
}
CChainState::CChainState(BlockManager& blockman,
std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
std::unique_ptr<llmq::CInstantSendManager>& isman,
std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
std::unique_ptr<CEvoDB>& evoDb,
const std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
const std::unique_ptr<llmq::CInstantSendManager>& isman,
const std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
CEvoDB& evoDb,
CTxMemPool& mempool,
uint256 from_snapshot_blockhash)
: m_mempool(mempool),
@ -1730,7 +1730,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
assert(m_quorum_block_processor);
bool fDIP0003Active = pindex->nHeight >= Params().GetConsensus().DIP0003Height;
if (fDIP0003Active && !m_evoDb->VerifyBestBlock(pindex->GetBlockHash())) {
if (fDIP0003Active && !m_evoDb.VerifyBestBlock(pindex->GetBlockHash())) {
// Nodes that upgraded after DIP3 activation will have to reindex to ensure evodb consistency
AbortNode("Found EvoDB inconsistency, you must reindex to continue");
return DISCONNECT_FAILED;
@ -1891,7 +1891,7 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
// move best block pointer to prevout block
view.SetBestBlock(pindex->pprev->GetBlockHash());
m_evoDb->WriteBestBlock(pindex->pprev->GetBlockHash());
m_evoDb.WriteBestBlock(pindex->pprev->GetBlockHash());
boost::posix_time::ptime finish = boost::posix_time::microsec_clock::local_time();
boost::posix_time::time_duration diff = finish - start;
@ -2126,7 +2126,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
if (pindex->pprev) {
bool fDIP0003Active = pindex->nHeight >= chainparams.GetConsensus().DIP0003Height;
if (fDIP0003Active && !m_evoDb->VerifyBestBlock(pindex->pprev->GetBlockHash())) {
if (fDIP0003Active && !m_evoDb.VerifyBestBlock(pindex->pprev->GetBlockHash())) {
// Nodes that upgraded after DIP3 activation will have to reindex to ensure evodb consistency
return AbortNode(state, "Found EvoDB inconsistency, you must reindex to continue");
}
@ -2521,7 +2521,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
int64_t nTime6 = GetTimeMicros(); nTimeIndex += nTime6 - nTime5;
LogPrint(BCLog::BENCHMARK, " - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime6 - nTime5), nTimeIndex * MICRO, nTimeIndex * MILLI / nBlocksTotal);
m_evoDb->WriteBestBlock(pindex->GetBlockHash());
m_evoDb.WriteBestBlock(pindex->GetBlockHash());
int64_t nTime7 = GetTimeMicros(); nTimeCallbacks += nTime7 - nTime6;
LogPrint(BCLog::BENCHMARK, " - Callbacks: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime7 - nTime6), nTimeCallbacks * MICRO, nTimeCallbacks * MILLI / nBlocksTotal);
@ -2624,7 +2624,7 @@ bool CChainState::FlushStateToDisk(
// The cache is over the limit, we have to write now.
bool fCacheCritical = mode == FlushStateMode::IF_NEEDED && cache_state >= CoinsCacheSizeState::CRITICAL;
// The evodb cache is too large
bool fEvoDbCacheCritical = mode == FlushStateMode::IF_NEEDED && m_evoDb != nullptr && m_evoDb->GetMemoryUsage() >= (64 << 20);
bool fEvoDbCacheCritical = mode == FlushStateMode::IF_NEEDED && m_evoDb.GetMemoryUsage() >= (64 << 20);
// It's been a while since we wrote the block index to disk. Do this frequently, so we don't need to redownload after a crash.
bool fPeriodicWrite = mode == FlushStateMode::PERIODIC && nNow > nLastWrite + DATABASE_WRITE_INTERVAL;
// It's been very long since we flushed the cache. Do this infrequently, to optimize cache usage.
@ -2689,7 +2689,7 @@ bool CChainState::FlushStateToDisk(
// Flush the chainstate (which may refer to block index entries).
if (!CoinsTip().Flush())
return AbortNode(state, "Failed to write to coin database");
if (!m_evoDb->CommitRootTransaction()) {
if (!m_evoDb.CommitRootTransaction()) {
return AbortNode(state, "Failed to commit EvoDB");
}
nLastFlush = nNow;
@ -2818,7 +2818,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, const CChainParams&
// Apply the block atomically to the chain state.
int64_t nStart = GetTimeMicros();
{
auto dbTx = m_evoDb->BeginTransaction();
auto dbTx = m_evoDb.BeginTransaction();
CCoinsViewCache view(&CoinsTip());
assert(view.GetBestBlock() == pindexDelete->GetBlockHash());
@ -2848,7 +2848,7 @@ bool CChainState::DisconnectTip(BlockValidationState& state, const CChainParams&
m_chain.SetTip(pindexDelete->pprev);
UpdateTip(m_mempool, pindexDelete->pprev, chainparams, *this, *m_evoDb);
UpdateTip(m_mempool, pindexDelete->pprev, chainparams, *this, m_evoDb);
// Let wallets know transactions went from 1-confirmed to
// 0-confirmed or conflicted:
GetMainSignals().BlockDisconnected(pblock, pindexDelete);
@ -2931,7 +2931,7 @@ bool CChainState::ConnectTip(BlockValidationState& state, const CChainParams& ch
int64_t nTime3;
LogPrint(BCLog::BENCHMARK, " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * MILLI, nTimeReadFromDisk * MICRO);
{
auto dbTx = m_evoDb->BeginTransaction();
auto dbTx = m_evoDb.BeginTransaction();
CCoinsViewCache view(&CoinsTip());
bool rv = ConnectBlock(blockConnecting, state, pindexNew, view, chainparams);
@ -2960,7 +2960,7 @@ bool CChainState::ConnectTip(BlockValidationState& state, const CChainParams& ch
disconnectpool.removeForBlock(blockConnecting.vtx);
// Update m_chain & related variables.
m_chain.SetTip(pindexNew);
UpdateTip(m_mempool, pindexNew, chainparams, *this, *m_evoDb);
UpdateTip(m_mempool, pindexNew, chainparams, *this, m_evoDb);
int64_t nTime6 = GetTimeMicros(); nTimePostConnect += nTime6 - nTime5; nTimeTotal += nTime6 - nTime1;
LogPrint(BCLog::BENCHMARK, " - Connect postprocess: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime6 - nTime5) * MILLI, nTimePostConnect * MICRO, nTimePostConnect * MILLI / nBlocksTotal);
@ -4939,7 +4939,7 @@ bool CChainState::ReplayBlocks(const CChainParams& params)
assert(pindexFork != nullptr);
}
auto dbTx = m_evoDb->BeginTransaction();
auto dbTx = m_evoDb.BeginTransaction();
// Rollback along the old branch.
while (pindexOld != pindexFork) {
@ -4974,7 +4974,7 @@ bool CChainState::ReplayBlocks(const CChainParams& params)
}
cache.SetBestBlock(pindexNew->GetBlockHash());
m_evoDb->WriteBestBlock(pindexNew->GetBlockHash());
m_evoDb.WriteBestBlock(pindexNew->GetBlockHash());
bool flushed = cache.Flush();
assert(flushed);
dbTx->Commit();
@ -5658,10 +5658,10 @@ std::vector<CChainState*> ChainstateManager::GetAll()
return out;
}
CChainState& ChainstateManager::InitializeChainstate(std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
std::unique_ptr<llmq::CInstantSendManager>& isman,
std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
std::unique_ptr<CEvoDB>& evoDb,
CChainState& ChainstateManager::InitializeChainstate(const std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
const std::unique_ptr<llmq::CInstantSendManager>& isman,
const std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
CEvoDB& evoDb,
CTxMemPool& mempool,
const uint256& snapshot_blockhash)
{

View File

@ -574,10 +574,10 @@ private:
std::unique_ptr<CoinsViews> m_coins_views;
//! Dash
std::unique_ptr<llmq::CChainLocksHandler>& m_clhandler;
std::unique_ptr<llmq::CInstantSendManager>& m_isman;
std::unique_ptr<llmq::CQuorumBlockProcessor>& m_quorum_block_processor;
std::unique_ptr<CEvoDB>& m_evoDb;
const std::unique_ptr<llmq::CChainLocksHandler>& m_clhandler;
const std::unique_ptr<llmq::CInstantSendManager>& m_isman;
const std::unique_ptr<llmq::CQuorumBlockProcessor>& m_quorum_block_processor;
CEvoDB& m_evoDb;
public:
//! Reference to a BlockManager instance which itself is shared across all
@ -585,10 +585,10 @@ public:
BlockManager& m_blockman;
explicit CChainState(BlockManager& blockman,
std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
std::unique_ptr<llmq::CInstantSendManager>& isman,
std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
std::unique_ptr<CEvoDB>& evoDb,
const std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
const std::unique_ptr<llmq::CInstantSendManager>& isman,
const std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
CEvoDB& evoDb,
CTxMemPool& mempool,
uint256 from_snapshot_blockhash = uint256());
@ -909,10 +909,10 @@ public:
// constructor
//! @param[in] snapshot_blockhash If given, signify that this chainstate
//! is based on a snapshot.
CChainState& InitializeChainstate(std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
std::unique_ptr<llmq::CInstantSendManager>& isman,
std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
std::unique_ptr<CEvoDB>& evoDb,
CChainState& InitializeChainstate(const std::unique_ptr<llmq::CChainLocksHandler>& clhandler,
const std::unique_ptr<llmq::CInstantSendManager>& isman,
const std::unique_ptr<llmq::CQuorumBlockProcessor>& quorum_block_processor,
CEvoDB& evoDb,
CTxMemPool& mempool,
const uint256& snapshot_blockhash = uint256()) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);

View File

@ -118,7 +118,8 @@ bool AddWallet(const std::shared_ptr<CWallet>& wallet)
vpwallets.push_back(wallet);
}
wallet->ConnectScriptPubKeyManNotifiers();
coinJoinClientManagers.emplace(std::make_pair(wallet->GetName(), std::make_shared<CCoinJoinClientManager>(*wallet, ::masternodeSync)));
assert(::masternodeSync != nullptr);
coinJoinClientManagers.emplace(std::make_pair(wallet->GetName(), std::make_shared<CCoinJoinClientManager>(*wallet, *::masternodeSync)));
g_wallet_init_interface.InitCoinJoinSettings();
return true;
}
@ -4793,7 +4794,8 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, const std::st
walletInstance->database->IncrementUpdateCounter();
}
coinJoinClientManagers.emplace(std::make_pair(walletInstance->GetName(), std::make_shared<CCoinJoinClientManager>(*walletInstance, ::masternodeSync)));
assert(::masternodeSync != nullptr);
coinJoinClientManagers.emplace(std::make_pair(walletInstance->GetName(), std::make_shared<CCoinJoinClientManager>(*walletInstance, *::masternodeSync)));
{
LOCK(cs_wallets);