5151
5252#include < spork.h>
5353#include < governance/governance.h>
54+ #include < masternode/active/context.h>
5455#include < masternode/sync.h>
5556#include < masternode/meta.h>
5657#ifdef ENABLE_WALLET
@@ -595,6 +596,7 @@ class PeerManagerImpl final : public PeerManager
595596 CGovernanceManager& govman, CSporkManager& sporkman,
596597 const CActiveMasternodeManager* const mn_activeman,
597598 const std::unique_ptr<CDeterministicMNManager>& dmnman,
599+ const std::unique_ptr<ActiveContext>& active_ctx,
598600 const std::unique_ptr<CJContext>& cj_ctx,
599601 const std::unique_ptr<LLMQContext>& llmq_ctx,
600602 bool ignore_incoming_txs);
@@ -776,6 +778,7 @@ class PeerManagerImpl final : public PeerManager
776778 CTxMemPool& m_mempool;
777779 std::unique_ptr<TxReconciliationTracker> m_txreconciliation;
778780 const std::unique_ptr<CDeterministicMNManager>& m_dmnman;
781+ const std::unique_ptr<ActiveContext>& m_active_ctx;
779782 const std::unique_ptr<CJContext>& m_cj_ctx;
780783 const std::unique_ptr<LLMQContext>& m_llmq_ctx;
781784 CMasternodeMetaMan& m_mn_metaman;
@@ -1948,10 +1951,11 @@ std::unique_ptr<PeerManager> PeerManager::make(const CChainParams& chainparams,
19481951 CGovernanceManager& govman, CSporkManager& sporkman,
19491952 const CActiveMasternodeManager* const mn_activeman,
19501953 const std::unique_ptr<CDeterministicMNManager>& dmnman,
1954+ const std::unique_ptr<ActiveContext>& active_ctx,
19511955 const std::unique_ptr<CJContext>& cj_ctx,
19521956 const std::unique_ptr<LLMQContext>& llmq_ctx, bool ignore_incoming_txs)
19531957{
1954- return std::make_unique<PeerManagerImpl>(chainparams, connman, addrman, banman, chainman, pool, mn_metaman, mn_sync, govman, sporkman, mn_activeman, dmnman, cj_ctx, llmq_ctx, ignore_incoming_txs);
1958+ return std::make_unique<PeerManagerImpl>(chainparams, connman, addrman, banman, chainman, pool, mn_metaman, mn_sync, govman, sporkman, mn_activeman, dmnman, active_ctx, cj_ctx, llmq_ctx, ignore_incoming_txs);
19551959}
19561960
19571961PeerManagerImpl::PeerManagerImpl (const CChainParams& chainparams, CConnman& connman, AddrMan& addrman, BanMan* banman,
@@ -1960,6 +1964,7 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
19601964 CGovernanceManager& govman, CSporkManager& sporkman,
19611965 const CActiveMasternodeManager* const mn_activeman,
19621966 const std::unique_ptr<CDeterministicMNManager>& dmnman,
1967+ const std::unique_ptr<ActiveContext>& active_ctx,
19631968 const std::unique_ptr<CJContext>& cj_ctx,
19641969 const std::unique_ptr<LLMQContext>& llmq_ctx,
19651970 bool ignore_incoming_txs)
@@ -1970,6 +1975,7 @@ PeerManagerImpl::PeerManagerImpl(const CChainParams& chainparams, CConnman& conn
19701975 m_chainman(chainman),
19711976 m_mempool(pool),
19721977 m_dmnman(dmnman),
1978+ m_active_ctx(active_ctx),
19731979 m_cj_ctx(cj_ctx),
19741980 m_llmq_ctx(llmq_ctx),
19751981 m_mn_metaman(mn_metaman),
@@ -2260,9 +2266,9 @@ bool PeerManagerImpl::AlreadyHave(const CInv& inv)
22602266 return m_llmq_ctx->isman ->AlreadyHave (inv);
22612267 case MSG_DSQ:
22622268#ifdef ENABLE_WALLET
2263- return m_cj_ctx->server ->HasQueue (inv.hash ) || m_cj_ctx-> queueman ->HasQueue (inv.hash );
2269+ return m_cj_ctx->queueman ->HasQueue (inv.hash ) || (m_active_ctx && m_active_ctx-> cj_server ->HasQueue (inv.hash ) );
22642270#else
2265- return m_cj_ctx-> server ->HasQueue (inv.hash );
2271+ return m_active_ctx && m_active_ctx-> cj_server ->HasQueue (inv.hash );
22662272#endif
22672273 }
22682274
@@ -2867,7 +2873,7 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
28672873 }
28682874 }
28692875 if (!push && inv.type == MSG_DSQ) {
2870- auto opt_dsq = m_cj_ctx-> server ->GetQueueFromHash (inv.hash );
2876+ auto opt_dsq = m_active_ctx ? m_active_ctx-> cj_server ->GetQueueFromHash (inv.hash ) : std:: nullopt ;
28712877#ifdef ENABLE_WALLET
28722878 if (!opt_dsq.has_value ()) {
28732879 opt_dsq = m_cj_ctx->queueman ->GetQueueFromHash (inv.hash );
@@ -5249,7 +5255,9 @@ void PeerManagerImpl::ProcessMessage(
52495255 clientman->ProcessMessage (pfrom, m_chainman.ActiveChainstate (), m_connman, m_mempool, msg_type, vRecv);
52505256 });
52515257#endif // ENABLE_WALLET
5252- PostProcessMessage (m_cj_ctx->server ->ProcessMessage (pfrom, msg_type, vRecv), pfrom.GetId ());
5258+ if (m_active_ctx) {
5259+ PostProcessMessage (m_active_ctx->cj_server ->ProcessMessage (pfrom, msg_type, vRecv), pfrom.GetId ());
5260+ }
52535261 PostProcessMessage (m_sporkman.ProcessMessage (pfrom, m_connman, msg_type, vRecv), pfrom.GetId ());
52545262 m_mn_sync.ProcessMessage (pfrom, msg_type, vRecv);
52555263 PostProcessMessage (m_govman.ProcessMessage (pfrom, m_connman, *this , msg_type, vRecv), pfrom.GetId ());
0 commit comments