mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
refactor: move CConnman
, PeerManager
out of CCoinJoinClientQueueManager
ctor
This commit is contained in:
parent
953ba96ac9
commit
7d26061170
@ -30,18 +30,20 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
PeerMsgRet CCoinJoinClientQueueManager::ProcessMessage(const CNode& peer, std::string_view msg_type, CDataStream& vRecv)
|
PeerMsgRet CCoinJoinClientQueueManager::ProcessMessage(const CNode& peer, CConnman& connman, PeerManager& peerman,
|
||||||
|
std::string_view msg_type, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
if (m_is_masternode) return {};
|
if (m_is_masternode) return {};
|
||||||
if (!m_mn_sync.IsBlockchainSynced()) return {};
|
if (!m_mn_sync.IsBlockchainSynced()) return {};
|
||||||
|
|
||||||
if (msg_type == NetMsgType::DSQUEUE) {
|
if (msg_type == NetMsgType::DSQUEUE) {
|
||||||
return CCoinJoinClientQueueManager::ProcessDSQueue(peer, vRecv);
|
return CCoinJoinClientQueueManager::ProcessDSQueue(peer, connman, peerman, vRecv);
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataStream& vRecv)
|
PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CConnman& connman, PeerManager& peerman,
|
||||||
|
CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
assert(m_mn_metaman.IsValid());
|
assert(m_mn_metaman.IsValid());
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataS
|
|||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
Assert(peerman)->EraseObjectRequest(peer.GetId(), CInv(MSG_DSQ, dsq.GetHash()));
|
peerman.EraseObjectRequest(peer.GetId(), CInv(MSG_DSQ, dsq.GetHash()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dsq.masternodeOutpoint.IsNull() && dsq.m_protxHash.IsNull()) {
|
if (dsq.masternodeOutpoint.IsNull() && dsq.m_protxHash.IsNull()) {
|
||||||
@ -102,8 +104,9 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if the queue is ready, submit if we can
|
// if the queue is ready, submit if we can
|
||||||
if (dsq.fReady && m_walletman.ForAnyCJClientMan([this, &dmn](std::unique_ptr<CCoinJoinClientManager>& clientman) {
|
if (dsq.fReady &&
|
||||||
return clientman->TrySubmitDenominate(dmn->pdmnState->addr, this->connman);
|
m_walletman.ForAnyCJClientMan([this, &connman, &dmn](std::unique_ptr<CCoinJoinClientManager>& clientman) {
|
||||||
|
return clientman->TrySubmitDenominate(dmn->pdmnState->addr, connman);
|
||||||
})) {
|
})) {
|
||||||
LogPrint(BCLog::COINJOIN, "DSQUEUE -- CoinJoin queue (%s) is ready on masternode %s\n", dsq.ToString(),
|
LogPrint(BCLog::COINJOIN, "DSQUEUE -- CoinJoin queue (%s) is ready on masternode %s\n", dsq.ToString(),
|
||||||
dmn->pdmnState->addr.ToStringAddrPort());
|
dmn->pdmnState->addr.ToStringAddrPort());
|
||||||
@ -132,7 +135,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataS
|
|||||||
WITH_LOCK(cs_vecqueue, vecCoinJoinQueue.push_back(dsq));
|
WITH_LOCK(cs_vecqueue, vecCoinJoinQueue.push_back(dsq));
|
||||||
}
|
}
|
||||||
} // cs_ProcessDSQueue
|
} // cs_ProcessDSQueue
|
||||||
peerman->RelayDSQ(dsq);
|
peerman.RelayDSQ(dsq);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,8 +232,6 @@ public:
|
|||||||
class CCoinJoinClientQueueManager : public CCoinJoinBaseManager
|
class CCoinJoinClientQueueManager : public CCoinJoinBaseManager
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CConnman& connman;
|
|
||||||
std::unique_ptr<PeerManager>& peerman;
|
|
||||||
CoinJoinWalletManager& m_walletman;
|
CoinJoinWalletManager& m_walletman;
|
||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
CMasternodeMetaMan& m_mn_metaman;
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
@ -243,20 +241,18 @@ private:
|
|||||||
const bool m_is_masternode;
|
const bool m_is_masternode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CCoinJoinClientQueueManager(CConnman& _connman, std::unique_ptr<PeerManager>& _peerman,
|
explicit CCoinJoinClientQueueManager(CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman,
|
||||||
CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman,
|
|
||||||
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync,
|
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync,
|
||||||
bool is_masternode) :
|
bool is_masternode) :
|
||||||
connman(_connman),
|
|
||||||
peerman(_peerman),
|
|
||||||
m_walletman(walletman),
|
m_walletman(walletman),
|
||||||
m_dmnman(dmnman),
|
m_dmnman(dmnman),
|
||||||
m_mn_metaman(mn_metaman),
|
m_mn_metaman(mn_metaman),
|
||||||
m_mn_sync(mn_sync),
|
m_mn_sync(mn_sync),
|
||||||
m_is_masternode{is_masternode} {};
|
m_is_masternode{is_masternode} {};
|
||||||
|
|
||||||
PeerMsgRet ProcessMessage(const CNode& peer, std::string_view msg_type, CDataStream& vRecv) EXCLUSIVE_LOCKS_REQUIRED(!cs_vecqueue);
|
PeerMsgRet ProcessMessage(const CNode& peer, CConnman& connman, PeerManager& peerman, std::string_view msg_type,
|
||||||
PeerMsgRet ProcessDSQueue(const CNode& peer, CDataStream& vRecv);
|
CDataStream& vRecv) EXCLUSIVE_LOCKS_REQUIRED(!cs_vecqueue);
|
||||||
|
PeerMsgRet ProcessDSQueue(const CNode& peer, CConnman& connman, PeerManager& peerman, CDataStream& vRecv);
|
||||||
void DoMaintenance();
|
void DoMaintenance();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,10 +17,9 @@ CJContext::CJContext(ChainstateManager& chainman, CConnman& connman, CDeterminis
|
|||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
walletman{std::make_unique<CoinJoinWalletManager>(chainman, dmnman, mn_metaman, mempool, mn_sync, queueman,
|
walletman{std::make_unique<CoinJoinWalletManager>(chainman, dmnman, mn_metaman, mempool, mn_sync, queueman,
|
||||||
/*is_masternode=*/mn_activeman != nullptr)},
|
/*is_masternode=*/mn_activeman != nullptr)},
|
||||||
queueman{relay_txes
|
queueman{relay_txes ? std::make_unique<CCoinJoinClientQueueManager>(*walletman, dmnman, mn_metaman, mn_sync,
|
||||||
? std::make_unique<CCoinJoinClientQueueManager>(connman, peerman, *walletman, dmnman, mn_metaman,
|
/*is_masternode=*/mn_activeman != nullptr)
|
||||||
mn_sync, /* is_masternode = */ mn_activeman != nullptr)
|
: nullptr},
|
||||||
: nullptr},
|
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
server{std::make_unique<CCoinJoinServer>(chainman, connman, dmnman, *dstxman, mn_metaman, mempool, mn_activeman,
|
server{std::make_unique<CCoinJoinServer>(chainman, connman, dmnman, *dstxman, mn_metaman, mempool, mn_activeman,
|
||||||
mn_sync, peerman)}
|
mn_sync, peerman)}
|
||||||
|
@ -5251,7 +5251,7 @@ void PeerManagerImpl::ProcessMessage(
|
|||||||
{
|
{
|
||||||
//probably one the extensions
|
//probably one the extensions
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
ProcessPeerMsgRet(m_cj_ctx->queueman->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(m_cj_ctx->queueman->ProcessMessage(pfrom, m_connman, *this, msg_type, vRecv), pfrom);
|
||||||
m_cj_ctx->walletman->ForEachCJClientMan([this, &pfrom, &msg_type, &vRecv](std::unique_ptr<CCoinJoinClientManager>& clientman) {
|
m_cj_ctx->walletman->ForEachCJClientMan([this, &pfrom, &msg_type, &vRecv](std::unique_ptr<CCoinJoinClientManager>& clientman) {
|
||||||
clientman->ProcessMessage(pfrom, m_chainman.ActiveChainstate(), m_connman, m_mempool, msg_type, vRecv);
|
clientman->ProcessMessage(pfrom, m_chainman.ActiveChainstate(), m_connman, m_mempool, msg_type, vRecv);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user