mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
refactor: remove CActiveMasternodeManager global, move to NodeContext
This commit is contained in:
parent
c99fb42ddf
commit
81b1247e6d
@ -26,12 +26,14 @@
|
||||
CDSNotificationInterface::CDSNotificationInterface(CConnman& connman,
|
||||
CMasternodeSync& mn_sync,
|
||||
CGovernanceManager& govman,
|
||||
const CActiveMasternodeManager* const mn_activeman,
|
||||
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
||||
const std::unique_ptr<LLMQContext>& llmq_ctx,
|
||||
const std::unique_ptr<CJContext>& cj_ctx)
|
||||
: m_connman(connman),
|
||||
m_mn_sync(mn_sync),
|
||||
m_govman(govman),
|
||||
m_mn_activeman(mn_activeman),
|
||||
m_dmnman(dmnman),
|
||||
m_llmq_ctx(llmq_ctx),
|
||||
m_cj_ctx(cj_ctx) {}
|
||||
@ -94,7 +96,7 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con
|
||||
m_llmq_ctx->qdkgsman->UpdatedBlockTip(pindexNew, fInitialDownload);
|
||||
m_llmq_ctx->ehfSignalsHandler->UpdatedBlockTip(pindexNew);
|
||||
|
||||
if (!fDisableGovernance) m_govman.UpdatedBlockTip(pindexNew, m_connman);
|
||||
if (!fDisableGovernance) m_govman.UpdatedBlockTip(pindexNew, m_connman, m_mn_activeman);
|
||||
}
|
||||
|
||||
void CDSNotificationInterface::TransactionAddedToMempool(const CTransactionRef& ptx, int64_t nAcceptTime)
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <validationinterface.h>
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class CConnman;
|
||||
class CDeterministicMNManager;
|
||||
class CGovernanceManager;
|
||||
@ -20,6 +21,7 @@ public:
|
||||
explicit CDSNotificationInterface(CConnman& connman,
|
||||
CMasternodeSync& mn_sync,
|
||||
CGovernanceManager& govman,
|
||||
const CActiveMasternodeManager* const mn_activeman,
|
||||
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
||||
const std::unique_ptr<LLMQContext>& llmq_ctx,
|
||||
const std::unique_ptr<CJContext>& cj_ctx);
|
||||
@ -47,6 +49,7 @@ private:
|
||||
CMasternodeSync& m_mn_sync;
|
||||
CGovernanceManager& m_govman;
|
||||
|
||||
const CActiveMasternodeManager* const m_mn_activeman;
|
||||
const std::unique_ptr<CDeterministicMNManager>& m_dmnman;
|
||||
const std::unique_ptr<LLMQContext>& m_llmq_ctx;
|
||||
const std::unique_ptr<CJContext>& m_cj_ctx;
|
||||
|
@ -19,12 +19,13 @@
|
||||
#include <util/time.h>
|
||||
#include <validation.h>
|
||||
|
||||
void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CBlockIndex* tip)
|
||||
void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman,
|
||||
const CBlockIndex* tip)
|
||||
{
|
||||
if (!fMasternodeMode) return;
|
||||
assert(fMasternodeMode);
|
||||
|
||||
CMNAuth mnauth;
|
||||
if (::activeMasternodeManager->GetProTxHash().IsNull()) {
|
||||
if (mn_activeman.GetProTxHash().IsNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -43,7 +44,7 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CBlockIndex* tip)
|
||||
nOurNodeVersion = gArgs.GetArg("-pushversion", PROTOCOL_VERSION);
|
||||
}
|
||||
const bool is_basic_scheme_active{DeploymentActiveAfter(tip, Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
|
||||
auto pk = ::activeMasternodeManager->GetPubKey();
|
||||
auto pk = mn_activeman.GetPubKey();
|
||||
const CBLSPublicKeyVersionWrapper pubKey(pk, !is_basic_scheme_active);
|
||||
uint256 signHash = [&]() {
|
||||
if (peer.nVersion < MNAUTH_NODE_VER_VERSION || nOurNodeVersion < MNAUTH_NODE_VER_VERSION) {
|
||||
@ -53,15 +54,15 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CBlockIndex* tip)
|
||||
}
|
||||
}();
|
||||
|
||||
mnauth.proRegTxHash = ::activeMasternodeManager->GetProTxHash();
|
||||
mnauth.proRegTxHash = mn_activeman.GetProTxHash();
|
||||
|
||||
mnauth.sig = ::activeMasternodeManager->Sign(signHash);
|
||||
mnauth.sig = mn_activeman.Sign(signHash);
|
||||
|
||||
LogPrint(BCLog::NET_NETCONN, "CMNAuth::%s -- Sending MNAUTH, peer=%d\n", __func__, peer.GetId());
|
||||
connman.PushMessage(&peer, CNetMsgMaker(peer.GetCommonVersion()).Make(NetMsgType::MNAUTH, mnauth));
|
||||
}
|
||||
|
||||
PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, const CMasternodeSync& mn_sync,
|
||||
PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||
const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv)
|
||||
{
|
||||
assert(::mmetaman->IsValid());
|
||||
@ -134,7 +135,7 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, const CMaster
|
||||
}
|
||||
|
||||
const uint256 myProTxHash = fMasternodeMode ?
|
||||
::activeMasternodeManager->GetProTxHash() :
|
||||
Assert(mn_activeman)->GetProTxHash() :
|
||||
uint256();
|
||||
|
||||
connman.ForEachNode([&](CNode* pnode2) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <net_types.h>
|
||||
#include <serialize.h>
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class CBlockIndex;
|
||||
class CConnman;
|
||||
class CDataStream;
|
||||
@ -49,13 +50,14 @@ public:
|
||||
READWRITE(obj.proRegTxHash, obj.sig);
|
||||
}
|
||||
|
||||
static void PushMNAUTH(CNode& peer, CConnman& connman, const CBlockIndex* tip);
|
||||
static void PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternodeManager& mn_activeman,
|
||||
const CBlockIndex* tip);
|
||||
|
||||
/**
|
||||
* @pre CMasternodeMetaMan's database must be successfully loaded before
|
||||
* attempting to call this function regardless of sync state
|
||||
*/
|
||||
static PeerMsgRet ProcessMessage(CNode& peer, CConnman& connman, const CMasternodeSync& mn_sync,
|
||||
static PeerMsgRet ProcessMessage(CNode& peer, CConnman& connman, const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||
const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv);
|
||||
static void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman);
|
||||
};
|
||||
|
@ -671,8 +671,11 @@ std::optional<const CSuperblock> CGovernanceManager::CreateSuperblockCandidate(i
|
||||
return CSuperblock(nNextSuperblock, std::move(payments));
|
||||
}
|
||||
|
||||
std::optional<const CGovernanceObject> CGovernanceManager::CreateGovernanceTrigger(const std::optional<const CSuperblock>& sb_opt, CConnman& connman)
|
||||
std::optional<const CGovernanceObject> CGovernanceManager::CreateGovernanceTrigger(const std::optional<const CSuperblock>& sb_opt, CConnman& connman,
|
||||
const CActiveMasternodeManager* const mn_activeman)
|
||||
{
|
||||
if (!fMasternodeMode) return std::nullopt;
|
||||
|
||||
// no sb_opt, no trigger
|
||||
if (!sb_opt.has_value()) return std::nullopt;
|
||||
|
||||
@ -696,12 +699,12 @@ std::optional<const CGovernanceObject> CGovernanceManager::CreateGovernanceTrigg
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (mn_payees.front()->proTxHash != ::activeMasternodeManager->GetProTxHash()) {
|
||||
if (mn_payees.front()->proTxHash != Assert(mn_activeman)->GetProTxHash()) {
|
||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s we are not the payee, skipping\n", __func__);
|
||||
return std::nullopt;
|
||||
}
|
||||
gov_sb.SetMasternodeOutpoint(::activeMasternodeManager->GetOutPoint());
|
||||
gov_sb.Sign(*::activeMasternodeManager);
|
||||
gov_sb.SetMasternodeOutpoint(mn_activeman->GetOutPoint());
|
||||
gov_sb.Sign(*mn_activeman);
|
||||
|
||||
if (std::string strError; !gov_sb.IsValidLocally(m_dmnman->GetListAtChainTip(), strError, true)) {
|
||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Created trigger is invalid:%s\n", __func__, strError);
|
||||
@ -718,11 +721,12 @@ std::optional<const CGovernanceObject> CGovernanceManager::CreateGovernanceTrigg
|
||||
return std::make_optional<CGovernanceObject>(gov_sb);
|
||||
}
|
||||
|
||||
void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGovernanceObject>& trigger_opt, CConnman& connman)
|
||||
void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGovernanceObject>& trigger_opt, CConnman& connman,
|
||||
const CActiveMasternodeManager* const mn_activeman)
|
||||
{
|
||||
// only active masternodes can vote on triggers
|
||||
if (!fMasternodeMode) return;
|
||||
if (::activeMasternodeManager->GetProTxHash().IsNull()) return;
|
||||
if (Assert(mn_activeman)->GetProTxHash().IsNull()) return;
|
||||
|
||||
LOCK2(cs_main, cs);
|
||||
|
||||
@ -731,7 +735,7 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover
|
||||
assert(!votedFundingYesTriggerHash.has_value());
|
||||
// Vote YES-FUNDING for the trigger we like
|
||||
const uint256 gov_sb_hash = trigger_opt.value().GetHash();
|
||||
if (!VoteFundingTrigger(gov_sb_hash, VOTE_OUTCOME_YES, connman)) {
|
||||
if (!VoteFundingTrigger(gov_sb_hash, VOTE_OUTCOME_YES, connman, mn_activeman)) {
|
||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Voting YES-FUNDING for new trigger:%s failed\n", __func__, gov_sb_hash.ToString());
|
||||
// this should never happen, bail out
|
||||
return;
|
||||
@ -754,7 +758,7 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover
|
||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Not voting NO-FUNDING for trigger:%s, we voted yes for it already\n", __func__, trigger_hash.ToString());
|
||||
continue;
|
||||
}
|
||||
if (!VoteFundingTrigger(trigger_hash, VOTE_OUTCOME_NO, connman)) {
|
||||
if (!VoteFundingTrigger(trigger_hash, VOTE_OUTCOME_NO, connman, mn_activeman)) {
|
||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Voting NO-FUNDING for trigger:%s failed\n", __func__, trigger_hash.ToString());
|
||||
// failing here is ok-ish
|
||||
continue;
|
||||
@ -763,11 +767,14 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover
|
||||
}
|
||||
}
|
||||
|
||||
bool CGovernanceManager::VoteFundingTrigger(const uint256& nHash, const vote_outcome_enum_t outcome, CConnman& connman)
|
||||
bool CGovernanceManager::VoteFundingTrigger(const uint256& nHash, const vote_outcome_enum_t outcome, CConnman& connman,
|
||||
const CActiveMasternodeManager* const mn_activeman)
|
||||
{
|
||||
CGovernanceVote vote(::activeMasternodeManager->GetOutPoint(), nHash, VOTE_SIGNAL_FUNDING, outcome);
|
||||
if (!fMasternodeMode) return false;
|
||||
|
||||
CGovernanceVote vote(Assert(mn_activeman)->GetOutPoint(), nHash, VOTE_SIGNAL_FUNDING, outcome);
|
||||
vote.SetTime(GetAdjustedTime());
|
||||
vote.Sign(*::activeMasternodeManager);
|
||||
vote.Sign(*mn_activeman);
|
||||
|
||||
CGovernanceException exception;
|
||||
if (!ProcessVoteAndRelay(vote, exception, connman)) {
|
||||
@ -1466,7 +1473,7 @@ UniValue CGovernanceManager::ToJson() const
|
||||
return jsonObj;
|
||||
}
|
||||
|
||||
void CGovernanceManager::UpdatedBlockTip(const CBlockIndex* pindex, CConnman& connman)
|
||||
void CGovernanceManager::UpdatedBlockTip(const CBlockIndex* pindex, CConnman& connman, const CActiveMasternodeManager* const mn_activeman)
|
||||
{
|
||||
// Note this gets called from ActivateBestChain without cs_main being held
|
||||
// so it should be safe to lock our mutex here without risking a deadlock
|
||||
@ -1478,8 +1485,8 @@ void CGovernanceManager::UpdatedBlockTip(const CBlockIndex* pindex, CConnman& co
|
||||
}
|
||||
|
||||
const auto sb_opt = CreateSuperblockCandidate(pindex->nHeight);
|
||||
const auto trigger_opt = CreateGovernanceTrigger(sb_opt, connman);
|
||||
VoteGovernanceTriggers(trigger_opt, connman);
|
||||
const auto trigger_opt = CreateGovernanceTrigger(sb_opt, connman, mn_activeman);
|
||||
VoteGovernanceTriggers(trigger_opt, connman, mn_activeman);
|
||||
|
||||
nCachedBlockHeight = pindex->nHeight;
|
||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight: %d\n", nCachedBlockHeight);
|
||||
|
@ -311,7 +311,7 @@ public:
|
||||
|
||||
UniValue ToJson() const;
|
||||
|
||||
void UpdatedBlockTip(const CBlockIndex* pindex, CConnman& connman);
|
||||
void UpdatedBlockTip(const CBlockIndex* pindex, CConnman& connman, const CActiveMasternodeManager* const mn_activeman);
|
||||
int64_t GetLastDiffTime() const { return nTimeLastDiff; }
|
||||
void UpdateLastDiffTime(int64_t nTimeIn) { nTimeLastDiff = nTimeIn; }
|
||||
|
||||
@ -366,9 +366,12 @@ public:
|
||||
|
||||
private:
|
||||
std::optional<const CSuperblock> CreateSuperblockCandidate(int nHeight) const;
|
||||
std::optional<const CGovernanceObject> CreateGovernanceTrigger(const std::optional<const CSuperblock>& sb_opt, CConnman& connman);
|
||||
void VoteGovernanceTriggers(const std::optional<const CGovernanceObject>& trigger_opt, CConnman& connman);
|
||||
bool VoteFundingTrigger(const uint256& nHash, const vote_outcome_enum_t outcome, CConnman& connman);
|
||||
std::optional<const CGovernanceObject> CreateGovernanceTrigger(const std::optional<const CSuperblock>& sb_opt, CConnman& connman,
|
||||
const CActiveMasternodeManager* const mn_activeman);
|
||||
void VoteGovernanceTriggers(const std::optional<const CGovernanceObject>& trigger_opt, CConnman& connman,
|
||||
const CActiveMasternodeManager* const mn_activeman);
|
||||
bool VoteFundingTrigger(const uint256& nHash, const vote_outcome_enum_t outcome, CConnman& connman,
|
||||
const CActiveMasternodeManager* const mn_activeman);
|
||||
bool HasAlreadyVotedFundingTrigger() const;
|
||||
|
||||
void RequestGovernanceObject(CNode* pfrom, const uint256& nHash, CConnman& connman, bool fUseFilter = false) const;
|
||||
|
22
src/init.cpp
22
src/init.cpp
@ -368,9 +368,8 @@ void PrepareShutdown(NodeContext& node)
|
||||
pdsNotificationInterface = nullptr;
|
||||
}
|
||||
if (fMasternodeMode) {
|
||||
UnregisterValidationInterface(node.mn_activeman);
|
||||
node.mn_activeman = nullptr;
|
||||
::activeMasternodeManager.reset();
|
||||
UnregisterValidationInterface(node.mn_activeman.get());
|
||||
node.mn_activeman.reset();
|
||||
}
|
||||
|
||||
node.chain_clients.clear();
|
||||
@ -1727,17 +1726,16 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
}
|
||||
fMasternodeMode = true;
|
||||
{
|
||||
// Create and register activeMasternodeManager, will init later in ThreadImport
|
||||
::activeMasternodeManager = std::make_unique<CActiveMasternodeManager>(keyOperator, *node.connman, ::deterministicMNManager);
|
||||
node.mn_activeman = ::activeMasternodeManager.get();
|
||||
RegisterValidationInterface(node.mn_activeman);
|
||||
// Create and register mn_activeman, will init later in ThreadImport
|
||||
node.mn_activeman = std::make_unique<CActiveMasternodeManager>(keyOperator, *node.connman, ::deterministicMNManager);
|
||||
RegisterValidationInterface(node.mn_activeman.get());
|
||||
}
|
||||
}
|
||||
|
||||
assert(!node.peerman);
|
||||
node.peerman = PeerManager::make(chainparams, *node.connman, *node.addrman, node.banman.get(),
|
||||
*node.scheduler, chainman, *node.mempool, *node.mn_metaman, *node.mn_sync,
|
||||
*node.govman, *node.sporkman, ::deterministicMNManager,
|
||||
*node.govman, *node.sporkman, node.mn_activeman.get(), ::deterministicMNManager,
|
||||
node.cj_ctx, node.llmq_ctx, ignores_incoming_txs);
|
||||
RegisterValidationInterface(node.peerman.get());
|
||||
|
||||
@ -1862,7 +1860,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
#endif
|
||||
|
||||
pdsNotificationInterface = new CDSNotificationInterface(
|
||||
*node.connman, *node.mn_sync, *node.govman, ::deterministicMNManager, node.llmq_ctx, node.cj_ctx
|
||||
*node.connman, *node.mn_sync, *node.govman, node.mn_activeman.get(), ::deterministicMNManager, node.llmq_ctx, node.cj_ctx
|
||||
);
|
||||
RegisterValidationInterface(pdsNotificationInterface);
|
||||
|
||||
@ -1961,7 +1959,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
}
|
||||
node.llmq_ctx.reset();
|
||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.evodb, *node.mnhf_manager, *node.sporkman,
|
||||
*node.mempool, node.mn_activeman, *node.mn_sync, node.peerman, /* unit_tests = */ false, /* wipe = */ fReset || fReindexChainState);
|
||||
*node.mempool, node.mn_activeman.get(), *node.mn_sync, node.peerman, /* unit_tests = */ false, /* wipe = */ fReset || fReindexChainState);
|
||||
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase
|
||||
node.llmq_ctx->Start();
|
||||
|
||||
@ -2206,7 +2204,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
|
||||
// ********************************************************* Step 7c: Setup CoinJoin
|
||||
|
||||
node.cj_ctx = std::make_unique<CJContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.mempool, node.mn_activeman,
|
||||
node.cj_ctx = std::make_unique<CJContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.mempool, node.mn_activeman.get(),
|
||||
*node.mn_sync, !ignores_incoming_txs);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
@ -2379,7 +2377,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
||||
}
|
||||
|
||||
chainman.m_load_block = std::thread(&util::TraceThread, "loadblk", [=, &args, &chainman, &node] {
|
||||
ThreadImport(chainman, *node.dmnman, *pdsNotificationInterface, vImportFiles, args);
|
||||
ThreadImport(chainman, *node.dmnman, *pdsNotificationInterface, vImportFiles, node.mn_activeman.get(), args);
|
||||
});
|
||||
|
||||
// Wait for genesis block to be processed
|
||||
|
@ -15,9 +15,6 @@
|
||||
#include <validation.h>
|
||||
#include <warnings.h>
|
||||
|
||||
// Keep track of the active Masternode
|
||||
std::unique_ptr<CActiveMasternodeManager> activeMasternodeManager;
|
||||
|
||||
CActiveMasternodeManager::CActiveMasternodeManager(const CBLSSecretKey& sk, CConnman& connman, const std::unique_ptr<CDeterministicMNManager>& dmnman) :
|
||||
m_info(sk, sk.GetPublicKey()),
|
||||
m_connman{connman},
|
||||
|
@ -80,6 +80,4 @@ private:
|
||||
bool GetLocalAddress(CService& addrRet) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
};
|
||||
|
||||
extern std::unique_ptr<CActiveMasternodeManager> activeMasternodeManager;
|
||||
|
||||
#endif // BITCOIN_MASTERNODE_NODE_H
|
||||
|
@ -297,6 +297,7 @@ public:
|
||||
CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool,
|
||||
CMasternodeMetaMan& mn_metaman, CMasternodeSync& mn_sync,
|
||||
CGovernanceManager& govman, CSporkManager& sporkman,
|
||||
const CActiveMasternodeManager* const mn_activeman,
|
||||
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
||||
const std::unique_ptr<CJContext>& cj_ctx,
|
||||
const std::unique_ptr<LLMQContext>& llmq_ctx,
|
||||
@ -423,6 +424,7 @@ private:
|
||||
CMasternodeSync& m_mn_sync;
|
||||
CGovernanceManager& m_govman;
|
||||
CSporkManager& m_sporkman;
|
||||
const CActiveMasternodeManager* const m_mn_activeman;
|
||||
|
||||
/** The height of the best chain */
|
||||
std::atomic<int> m_best_height{-1};
|
||||
@ -1735,17 +1737,19 @@ std::unique_ptr<PeerManager> PeerManager::make(const CChainParams& chainparams,
|
||||
CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool,
|
||||
CMasternodeMetaMan& mn_metaman, CMasternodeSync& mn_sync,
|
||||
CGovernanceManager& govman, CSporkManager& sporkman,
|
||||
const CActiveMasternodeManager* const mn_activeman,
|
||||
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
||||
const std::unique_ptr<CJContext>& cj_ctx,
|
||||
const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs)
|
||||
{
|
||||
return std::make_unique<PeerManagerImpl>(chainparams, connman, addrman, banman, scheduler, chainman, pool, mn_metaman, mn_sync, govman, sporkman, dmnman, cj_ctx, llmq_ctx, ignore_incoming_txs);
|
||||
return std::make_unique<PeerManagerImpl>(chainparams, connman, addrman, banman, scheduler, chainman, pool, mn_metaman, mn_sync, govman, sporkman, mn_activeman, dmnman, cj_ctx, llmq_ctx, ignore_incoming_txs);
|
||||
}
|
||||
|
||||
PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman, BanMan* banman,
|
||||
CScheduler &scheduler, ChainstateManager& chainman, CTxMemPool& pool,
|
||||
CMasternodeMetaMan& mn_metaman, CMasternodeSync& mn_sync,
|
||||
CGovernanceManager& govman, CSporkManager& sporkman,
|
||||
const CActiveMasternodeManager* const mn_activeman,
|
||||
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
||||
const std::unique_ptr<CJContext>& cj_ctx,
|
||||
const std::unique_ptr<LLMQContext>& llmq_ctx,
|
||||
@ -1763,6 +1767,7 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
|
||||
m_mn_sync(mn_sync),
|
||||
m_govman(govman),
|
||||
m_sporkman(sporkman),
|
||||
m_mn_activeman(mn_activeman),
|
||||
m_ignore_incoming_txs(ignore_incoming_txs)
|
||||
{
|
||||
assert(std::addressof(g_chainman) == std::addressof(m_chainman));
|
||||
@ -3293,8 +3298,8 @@ void PeerManagerImpl::ProcessMessage(
|
||||
pfrom.ConnectionTypeAsString());
|
||||
}
|
||||
|
||||
if (!pfrom.m_masternode_probe_connection) {
|
||||
CMNAuth::PushMNAUTH(pfrom, m_connman, m_chainman.ActiveChain().Tip());
|
||||
if (fMasternodeMode && !pfrom.m_masternode_probe_connection) {
|
||||
CMNAuth::PushMNAUTH(pfrom, m_connman, *Assert(m_mn_activeman), m_chainman.ActiveChain().Tip());
|
||||
}
|
||||
|
||||
// Tell our peer we prefer to receive headers rather than inv's
|
||||
@ -4625,7 +4630,7 @@ void PeerManagerImpl::ProcessMessage(
|
||||
ProcessPeerMsgRet(m_sporkman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
|
||||
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
|
||||
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, m_connman, m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, m_connman, m_mn_activeman, m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(m_llmq_ctx->quorum_block_processor->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(m_llmq_ctx->qdkgsman->ProcessMessage(pfrom, this, msg_type, vRecv), pfrom);
|
||||
ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class CAddrMan;
|
||||
class CTxMemPool;
|
||||
class CDeterministicMNManager;
|
||||
@ -52,6 +53,7 @@ public:
|
||||
BanMan* banman, CScheduler &scheduler, ChainstateManager& chainman,
|
||||
CTxMemPool& pool, CMasternodeMetaMan& mn_metaman, CMasternodeSync& mn_sync,
|
||||
CGovernanceManager& govman, CSporkManager& sporkman,
|
||||
const CActiveMasternodeManager* const mn_activeman,
|
||||
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
||||
const std::unique_ptr<CJContext>& cj_ctx,
|
||||
const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs);
|
||||
|
@ -120,7 +120,7 @@ struct CImportingNow {
|
||||
};
|
||||
|
||||
void ThreadImport(ChainstateManager& chainman, CDeterministicMNManager& dmnman, CDSNotificationInterface& dsnfi,
|
||||
std::vector<fs::path> vImportFiles, const ArgsManager& args)
|
||||
std::vector<fs::path> vImportFiles, CActiveMasternodeManager* const mn_activeman, const ArgsManager& args)
|
||||
{
|
||||
ScheduleBatchPriority();
|
||||
|
||||
@ -210,8 +210,7 @@ void ThreadImport(ChainstateManager& chainman, CDeterministicMNManager& dmnman,
|
||||
}
|
||||
|
||||
if (fMasternodeMode) {
|
||||
assert(activeMasternodeManager);
|
||||
activeMasternodeManager->Init(::ChainActive().Tip());
|
||||
Assert(mn_activeman)->Init(::ChainActive().Tip());
|
||||
}
|
||||
|
||||
g_wallet_init_interface.AutoLockMasternodeCollaterals();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
class CActiveMasternodeManager;
|
||||
class ArgsManager;
|
||||
class CBlock;
|
||||
class CBlockIndex;
|
||||
@ -36,6 +37,6 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex);
|
||||
FlatFilePos SaveBlockToDisk(const CBlock& block, int nHeight, CChain& active_chain, const CChainParams& chainparams, const FlatFilePos* dbp);
|
||||
|
||||
void ThreadImport(ChainstateManager& chainman, CDeterministicMNManager& dmnman, CDSNotificationInterface& dsnfi,
|
||||
std::vector<fs::path> vImportFiles, const ArgsManager& args);
|
||||
std::vector<fs::path> vImportFiles, CActiveMasternodeManager* const mn_activeman, const ArgsManager& args);
|
||||
|
||||
#endif // BITCOIN_NODE_BLOCKSTORAGE_H
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <interfaces/chain.h>
|
||||
#include <interfaces/coinjoin.h>
|
||||
#include <llmq/context.h>
|
||||
#include <masternode/node.h>
|
||||
#include <masternode/sync.h>
|
||||
#include <net.h>
|
||||
#include <netfulfilledman.h>
|
||||
|
@ -71,6 +71,7 @@ struct NodeContext {
|
||||
std::unique_ptr<CScheduler> scheduler;
|
||||
std::function<void()> rpc_interruption_point = [] {};
|
||||
//! Dash
|
||||
std::unique_ptr<CActiveMasternodeManager> mn_activeman;
|
||||
std::unique_ptr<CCreditPoolManager> cpoolman;
|
||||
std::unique_ptr<CEvoDB> evodb;
|
||||
std::unique_ptr<CChainstateHelper> chain_helper;
|
||||
@ -81,7 +82,6 @@ struct NodeContext {
|
||||
std::unique_ptr<CNetFulfilledRequestManager> netfulfilledman;
|
||||
std::unique_ptr<CSporkManager> sporkman;
|
||||
std::unique_ptr<LLMQContext> llmq_ctx;
|
||||
CActiveMasternodeManager* mn_activeman{nullptr};
|
||||
CDeterministicMNManager* dmnman{nullptr};
|
||||
CMasternodeMetaMan* mn_metaman{nullptr};
|
||||
|
||||
|
@ -884,7 +884,7 @@ static UniValue _quorum(const JSONRPCRequest& request)
|
||||
} else if (command == "quorumdkginfo") {
|
||||
return quorum_dkginfo(new_request, llmq_ctx, chainman);
|
||||
} else if (command == "quorumdkgstatus") {
|
||||
return quorum_dkgstatus(new_request, *node.dmnman, node.mn_activeman, chainman, *node.sporkman, llmq_ctx);
|
||||
return quorum_dkgstatus(new_request, *node.dmnman, node.mn_activeman.get(), chainman, *node.sporkman, llmq_ctx);
|
||||
} else if (command == "quorummemberof") {
|
||||
return quorum_memberof(new_request, chainman, node, llmq_ctx);
|
||||
} else if (command == "quorumsign" || command == "quorumverify" || command == "quorumhasrecsig" || command == "quorumgetrecsig" || command == "quorumisconflicting") {
|
||||
|
@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
|
||||
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler,
|
||||
*m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
||||
*m_node.govman, *m_node.sporkman, ::deterministicMNManager,
|
||||
*m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, ::deterministicMNManager,
|
||||
m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false);
|
||||
|
||||
// Mock an outbound peer
|
||||
@ -138,7 +138,7 @@ BOOST_AUTO_TEST_CASE(stale_tip_peer_management)
|
||||
auto connman = std::make_unique<ConnmanTestMsg>(0x1337, 0x1337, *m_node.addrman);
|
||||
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, nullptr, *m_node.scheduler,
|
||||
*m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
||||
*m_node.govman, *m_node.sporkman, ::deterministicMNManager,
|
||||
*m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, ::deterministicMNManager,
|
||||
m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false);
|
||||
|
||||
constexpr int max_outbound_full_relay = MAX_OUTBOUND_FULL_RELAY_CONNECTIONS;
|
||||
@ -213,7 +213,7 @@ BOOST_AUTO_TEST_CASE(peer_discouragement)
|
||||
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
|
||||
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
|
||||
*m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
||||
*m_node.govman, *m_node.sporkman, ::deterministicMNManager,
|
||||
*m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, ::deterministicMNManager,
|
||||
m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false);
|
||||
|
||||
banman->ClearBanned();
|
||||
@ -261,7 +261,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||
auto connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman);
|
||||
auto peerLogic = PeerManager::make(chainparams, *connman, *m_node.addrman, banman.get(), *m_node.scheduler,
|
||||
*m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
||||
*m_node.govman, *m_node.sporkman, ::deterministicMNManager,
|
||||
*m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, ::deterministicMNManager,
|
||||
m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false);
|
||||
|
||||
banman->ClearBanned();
|
||||
|
@ -284,8 +284,8 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
|
||||
m_node.banman = std::make_unique<BanMan>(GetDataDir() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
|
||||
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman, m_node.banman.get(),
|
||||
*m_node.scheduler, *m_node.chainman, *m_node.mempool, *m_node.mn_metaman, *m_node.mn_sync,
|
||||
*m_node.govman, *m_node.sporkman, ::deterministicMNManager, m_node.cj_ctx, m_node.llmq_ctx,
|
||||
/* ignore_incoming_txs = */ false);
|
||||
*m_node.govman, *m_node.sporkman, /* mn_activeman = */ nullptr, ::deterministicMNManager,
|
||||
m_node.cj_ctx, m_node.llmq_ctx, /* ignore_incoming_txs = */ false);
|
||||
{
|
||||
CConnman::Options options;
|
||||
options.m_msgproc = m_node.peerman.get();
|
||||
|
Loading…
Reference in New Issue
Block a user