mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
refactor: remove CMasternodeMetaMan global, move to NodeContext
This commit is contained in:
parent
81b1247e6d
commit
cf90cf20c6
@ -42,7 +42,7 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessMessage(const CNode& peer, std::s
|
|||||||
|
|
||||||
PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataStream& vRecv)
|
PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
assert(::mmetaman->IsValid());
|
assert(m_mn_metaman.IsValid());
|
||||||
|
|
||||||
CCoinJoinQueue dsq;
|
CCoinJoinQueue dsq;
|
||||||
vRecv >> dsq;
|
vRecv >> dsq;
|
||||||
@ -105,18 +105,18 @@ PeerMsgRet CCoinJoinClientQueueManager::ProcessDSQueue(const CNode& peer, CDataS
|
|||||||
dmn->pdmnState->addr.ToString());
|
dmn->pdmnState->addr.ToString());
|
||||||
return {};
|
return {};
|
||||||
} else {
|
} else {
|
||||||
int64_t nLastDsq = mmetaman->GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
int64_t nLastDsq = m_mn_metaman.GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
||||||
int64_t nDsqThreshold = mmetaman->GetDsqThreshold(dmn->proTxHash, tip_mn_list.GetValidMNsCount());
|
int64_t nDsqThreshold = m_mn_metaman.GetDsqThreshold(dmn->proTxHash, tip_mn_list.GetValidMNsCount());
|
||||||
LogPrint(BCLog::COINJOIN, "DSQUEUE -- nLastDsq: %d nDsqThreshold: %d nDsqCount: %d\n", nLastDsq,
|
LogPrint(BCLog::COINJOIN, "DSQUEUE -- nLastDsq: %d nDsqThreshold: %d nDsqCount: %d\n", nLastDsq,
|
||||||
nDsqThreshold, mmetaman->GetDsqCount());
|
nDsqThreshold, m_mn_metaman.GetDsqCount());
|
||||||
// don't allow a few nodes to dominate the queuing process
|
// don't allow a few nodes to dominate the queuing process
|
||||||
if (nLastDsq != 0 && nDsqThreshold > mmetaman->GetDsqCount()) {
|
if (nLastDsq != 0 && nDsqThreshold > m_mn_metaman.GetDsqCount()) {
|
||||||
LogPrint(BCLog::COINJOIN, "DSQUEUE -- Masternode %s is sending too many dsq messages\n",
|
LogPrint(BCLog::COINJOIN, "DSQUEUE -- Masternode %s is sending too many dsq messages\n",
|
||||||
dmn->proTxHash.ToString());
|
dmn->proTxHash.ToString());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
mmetaman->AllowMixing(dmn->proTxHash);
|
m_mn_metaman.AllowMixing(dmn->proTxHash);
|
||||||
|
|
||||||
LogPrint(BCLog::COINJOIN, "DSQUEUE -- new CoinJoin queue (%s) from masternode %s\n", dsq.ToString(),
|
LogPrint(BCLog::COINJOIN, "DSQUEUE -- new CoinJoin queue (%s) from masternode %s\n", dsq.ToString(),
|
||||||
dmn->pdmnState->addr.ToString());
|
dmn->pdmnState->addr.ToString());
|
||||||
@ -155,12 +155,13 @@ void CCoinJoinClientManager::ProcessMessage(CNode& peer, CConnman& connman, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CCoinJoinClientSession::CCoinJoinClientSession(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman, const CMasternodeSync& mn_sync,
|
CCoinJoinClientSession::CCoinJoinClientSession(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
|
||||||
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
|
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
|
||||||
m_wallet(wallet),
|
m_wallet(wallet),
|
||||||
m_walletman(walletman),
|
m_walletman(walletman),
|
||||||
m_manager(*Assert(walletman.Get(wallet.GetName()))),
|
m_manager(*Assert(walletman.Get(wallet.GetName()))),
|
||||||
m_dmnman(dmnman),
|
m_dmnman(dmnman),
|
||||||
|
m_mn_metaman(mn_metaman),
|
||||||
m_mn_sync(mn_sync),
|
m_mn_sync(mn_sync),
|
||||||
m_queueman(queueman)
|
m_queueman(queueman)
|
||||||
{}
|
{}
|
||||||
@ -990,7 +991,7 @@ bool CCoinJoinClientManager::DoAutomaticDenominating(CConnman& connman, CTxMemPo
|
|||||||
AssertLockNotHeld(cs_deqsessions);
|
AssertLockNotHeld(cs_deqsessions);
|
||||||
LOCK(cs_deqsessions);
|
LOCK(cs_deqsessions);
|
||||||
if (int(deqSessions.size()) < CCoinJoinClientOptions::GetSessions()) {
|
if (int(deqSessions.size()) < CCoinJoinClientOptions::GetSessions()) {
|
||||||
deqSessions.emplace_back(m_wallet, m_walletman, m_dmnman, m_mn_sync, m_queueman);
|
deqSessions.emplace_back(m_wallet, m_walletman, m_dmnman, m_mn_metaman, m_mn_sync, m_queueman);
|
||||||
}
|
}
|
||||||
for (auto& session : deqSessions) {
|
for (auto& session : deqSessions) {
|
||||||
if (!CheckAutomaticBackup()) return false;
|
if (!CheckAutomaticBackup()) return false;
|
||||||
@ -1119,7 +1120,7 @@ bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized,
|
|||||||
|
|
||||||
bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CConnman& connman)
|
bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CConnman& connman)
|
||||||
{
|
{
|
||||||
assert(::mmetaman->IsValid());
|
assert(m_mn_metaman.IsValid());
|
||||||
|
|
||||||
if (!CCoinJoinClientOptions::IsEnabled()) return false;
|
if (!CCoinJoinClientOptions::IsEnabled()) return false;
|
||||||
if (nBalanceNeedsAnonymized <= 0) return false;
|
if (nBalanceNeedsAnonymized <= 0) return false;
|
||||||
@ -1156,13 +1157,13 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nLastDsq = mmetaman->GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
int64_t nLastDsq = m_mn_metaman.GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
||||||
int64_t nDsqThreshold = mmetaman->GetDsqThreshold(dmn->proTxHash, nMnCount);
|
int64_t nDsqThreshold = m_mn_metaman.GetDsqThreshold(dmn->proTxHash, nMnCount);
|
||||||
if (nLastDsq != 0 && nDsqThreshold > mmetaman->GetDsqCount()) {
|
if (nLastDsq != 0 && nDsqThreshold > m_mn_metaman.GetDsqCount()) {
|
||||||
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::StartNewQueue -- Too early to mix on this masternode!" /* Continued */
|
WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::StartNewQueue -- Too early to mix on this masternode!" /* Continued */
|
||||||
" masternode=%s addr=%s nLastDsq=%d nDsqThreshold=%d nDsqCount=%d\n",
|
" masternode=%s addr=%s nLastDsq=%d nDsqThreshold=%d nDsqCount=%d\n",
|
||||||
dmn->proTxHash.ToString(), dmn->pdmnState->addr.ToString(), nLastDsq,
|
dmn->proTxHash.ToString(), dmn->pdmnState->addr.ToString(), nLastDsq,
|
||||||
nDsqThreshold, mmetaman->GetDsqCount());
|
nDsqThreshold, m_mn_metaman.GetDsqCount());
|
||||||
nTries++;
|
nTries++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1892,7 +1893,7 @@ void CCoinJoinClientManager::GetJsonInfo(UniValue& obj) const
|
|||||||
void CoinJoinWalletManager::Add(CWallet& wallet) {
|
void CoinJoinWalletManager::Add(CWallet& wallet) {
|
||||||
m_wallet_manager_map.try_emplace(
|
m_wallet_manager_map.try_emplace(
|
||||||
wallet.GetName(),
|
wallet.GetName(),
|
||||||
std::make_unique<CCoinJoinClientManager>(wallet, *this, m_dmnman, m_mn_sync, m_queueman)
|
std::make_unique<CCoinJoinClientManager>(wallet, *this, m_dmnman, m_mn_metaman, m_mn_sync, m_queueman)
|
||||||
);
|
);
|
||||||
g_wallet_init_interface.InitCoinJoinSettings(*this);
|
g_wallet_init_interface.InitCoinJoinSettings(*this);
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,10 @@ class CCoinJoinClientQueueManager;
|
|||||||
class CConnman;
|
class CConnman;
|
||||||
class CDeterministicMN;
|
class CDeterministicMN;
|
||||||
class CDeterministicMNManager;
|
class CDeterministicMNManager;
|
||||||
class CoinJoinWalletManager;
|
|
||||||
class CNode;
|
class CNode;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CMasternodeSync;
|
class CMasternodeSync;
|
||||||
|
class CoinJoinWalletManager;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
|
|
||||||
class UniValue;
|
class UniValue;
|
||||||
@ -72,9 +73,10 @@ public:
|
|||||||
using wallet_name_cjman_map = std::map<const std::string, std::unique_ptr<CCoinJoinClientManager>>;
|
using wallet_name_cjman_map = std::map<const std::string, std::unique_ptr<CCoinJoinClientManager>>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CoinJoinWalletManager(CConnman& connman, CDeterministicMNManager& dmnman, CTxMemPool& mempool, const CMasternodeSync& mn_sync,
|
CoinJoinWalletManager(CConnman& connman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool,
|
||||||
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman)
|
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman)
|
||||||
: m_connman(connman), m_dmnman(dmnman), m_mempool(mempool), m_mn_sync(mn_sync), m_queueman(queueman) {}
|
: m_connman(connman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mempool(mempool), m_mn_sync(mn_sync), m_queueman(queueman) {}
|
||||||
|
|
||||||
~CoinJoinWalletManager() {
|
~CoinJoinWalletManager() {
|
||||||
for (auto& [wallet_name, cj_man] : m_wallet_manager_map) {
|
for (auto& [wallet_name, cj_man] : m_wallet_manager_map) {
|
||||||
cj_man.reset();
|
cj_man.reset();
|
||||||
@ -94,6 +96,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
CConnman& m_connman;
|
CConnman& m_connman;
|
||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
CTxMemPool& m_mempool;
|
CTxMemPool& m_mempool;
|
||||||
const CMasternodeSync& m_mn_sync;
|
const CMasternodeSync& m_mn_sync;
|
||||||
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
|
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
|
||||||
@ -108,6 +111,7 @@ private:
|
|||||||
CoinJoinWalletManager& m_walletman;
|
CoinJoinWalletManager& m_walletman;
|
||||||
CCoinJoinClientManager& m_manager;
|
CCoinJoinClientManager& m_manager;
|
||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
const CMasternodeSync& m_mn_sync;
|
const CMasternodeSync& m_mn_sync;
|
||||||
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
|
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
|
||||||
|
|
||||||
@ -157,8 +161,8 @@ private:
|
|||||||
void SetNull() override EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin);
|
void SetNull() override EXCLUSIVE_LOCKS_REQUIRED(cs_coinjoin);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CCoinJoinClientSession(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman, const CMasternodeSync& mn_sync,
|
explicit CCoinJoinClientSession(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
|
||||||
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman);
|
const CMasternodeSync& mn_sync, const std::unique_ptr<CCoinJoinClientQueueManager>& queueman);
|
||||||
|
|
||||||
void ProcessMessage(CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv);
|
void ProcessMessage(CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv);
|
||||||
|
|
||||||
@ -191,13 +195,14 @@ private:
|
|||||||
CConnman& connman;
|
CConnman& connman;
|
||||||
CoinJoinWalletManager& m_walletman;
|
CoinJoinWalletManager& m_walletman;
|
||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
const CMasternodeSync& m_mn_sync;
|
const CMasternodeSync& m_mn_sync;
|
||||||
mutable Mutex cs_ProcessDSQueue;
|
mutable Mutex cs_ProcessDSQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CCoinJoinClientQueueManager(CConnman& _connman, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman,
|
explicit CCoinJoinClientQueueManager(CConnman& _connman, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman,
|
||||||
const CMasternodeSync& mn_sync) :
|
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync) :
|
||||||
connman(_connman), m_walletman(walletman), m_dmnman(dmnman), m_mn_sync(mn_sync) {};
|
connman(_connman), m_walletman(walletman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mn_sync(mn_sync) {};
|
||||||
|
|
||||||
PeerMsgRet ProcessMessage(const CNode& peer, std::string_view msg_type, CDataStream& vRecv) LOCKS_EXCLUDED(cs_vecqueue);
|
PeerMsgRet ProcessMessage(const CNode& peer, std::string_view msg_type, CDataStream& vRecv) LOCKS_EXCLUDED(cs_vecqueue);
|
||||||
PeerMsgRet ProcessDSQueue(const CNode& peer, CDataStream& vRecv);
|
PeerMsgRet ProcessDSQueue(const CNode& peer, CDataStream& vRecv);
|
||||||
@ -212,6 +217,7 @@ private:
|
|||||||
CWallet& m_wallet;
|
CWallet& m_wallet;
|
||||||
CoinJoinWalletManager& m_walletman;
|
CoinJoinWalletManager& m_walletman;
|
||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
const CMasternodeSync& m_mn_sync;
|
const CMasternodeSync& m_mn_sync;
|
||||||
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
|
const std::unique_ptr<CCoinJoinClientQueueManager>& m_queueman;
|
||||||
|
|
||||||
@ -244,9 +250,10 @@ public:
|
|||||||
CCoinJoinClientManager(CCoinJoinClientManager const&) = delete;
|
CCoinJoinClientManager(CCoinJoinClientManager const&) = delete;
|
||||||
CCoinJoinClientManager& operator=(CCoinJoinClientManager const&) = delete;
|
CCoinJoinClientManager& operator=(CCoinJoinClientManager const&) = delete;
|
||||||
|
|
||||||
explicit CCoinJoinClientManager(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman, const CMasternodeSync& mn_sync,
|
explicit CCoinJoinClientManager(CWallet& wallet, CoinJoinWalletManager& walletman, CDeterministicMNManager& dmnman,
|
||||||
|
CMasternodeMetaMan& mn_metaman, const CMasternodeSync& mn_sync,
|
||||||
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
|
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman) :
|
||||||
m_wallet(wallet), m_walletman(walletman), m_dmnman(dmnman), m_mn_sync(mn_sync), m_queueman(queueman) {}
|
m_wallet(wallet), m_walletman(walletman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mn_sync(mn_sync), m_queueman(queueman) {}
|
||||||
|
|
||||||
void ProcessMessage(CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv) LOCKS_EXCLUDED(cs_deqsessions);
|
void ProcessMessage(CNode& peer, CConnman& connman, const CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv) LOCKS_EXCLUDED(cs_deqsessions);
|
||||||
|
|
||||||
|
@ -13,14 +13,15 @@
|
|||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
#include <coinjoin/server.h>
|
#include <coinjoin/server.h>
|
||||||
|
|
||||||
CJContext::CJContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CTxMemPool& mempool,
|
CJContext::CJContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
|
||||||
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync, bool relay_txes) :
|
CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||||
|
bool relay_txes) :
|
||||||
dstxman{std::make_unique<CDSTXManager>()},
|
dstxman{std::make_unique<CDSTXManager>()},
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
walletman{std::make_unique<CoinJoinWalletManager>(connman, dmnman, mempool, mn_sync, queueman)},
|
walletman{std::make_unique<CoinJoinWalletManager>(connman, dmnman, mn_metaman, mempool, mn_sync, queueman)},
|
||||||
queueman {relay_txes ? std::make_unique<CCoinJoinClientQueueManager>(connman, *walletman, dmnman, mn_sync) : nullptr},
|
queueman {relay_txes ? std::make_unique<CCoinJoinClientQueueManager>(connman, *walletman, dmnman, mn_metaman, mn_sync) : nullptr},
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
server{std::make_unique<CCoinJoinServer>(chainstate, connman, dmnman, *dstxman, mempool, mn_activeman, mn_sync)}
|
server{std::make_unique<CCoinJoinServer>(chainstate, connman, dmnman, *dstxman, mn_metaman, mempool, mn_activeman, mn_sync)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CJContext::~CJContext() {}
|
CJContext::~CJContext() {}
|
||||||
|
@ -18,6 +18,7 @@ class CCoinJoinServer;
|
|||||||
class CConnman;
|
class CConnman;
|
||||||
class CDeterministicMNManager;
|
class CDeterministicMNManager;
|
||||||
class CDSTXManager;
|
class CDSTXManager;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CMasternodeSync;
|
class CMasternodeSync;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
|
|
||||||
@ -29,8 +30,9 @@ class CoinJoinWalletManager;
|
|||||||
struct CJContext {
|
struct CJContext {
|
||||||
CJContext() = delete;
|
CJContext() = delete;
|
||||||
CJContext(const CJContext&) = delete;
|
CJContext(const CJContext&) = delete;
|
||||||
CJContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CTxMemPool& mempool,
|
CJContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
|
||||||
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync, bool relay_txes);
|
CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||||
|
bool relay_txes);
|
||||||
~CJContext();
|
~CJContext();
|
||||||
|
|
||||||
const std::unique_ptr<CDSTXManager> dstxman;
|
const std::unique_ptr<CDSTXManager> dstxman;
|
||||||
|
@ -44,7 +44,7 @@ PeerMsgRet CCoinJoinServer::ProcessMessage(CNode& peer, std::string_view msg_typ
|
|||||||
void CCoinJoinServer::ProcessDSACCEPT(CNode& peer, CDataStream& vRecv)
|
void CCoinJoinServer::ProcessDSACCEPT(CNode& peer, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
assert(m_mn_activeman);
|
assert(m_mn_activeman);
|
||||||
assert(::mmetaman->IsValid());
|
assert(m_mn_metaman.IsValid());
|
||||||
|
|
||||||
if (IsSessionReady()) {
|
if (IsSessionReady()) {
|
||||||
// too many users in this session already, reject new ones
|
// too many users in this session already, reject new ones
|
||||||
@ -81,9 +81,9 @@ void CCoinJoinServer::ProcessDSACCEPT(CNode& peer, CDataStream& vRecv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nLastDsq = mmetaman->GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
int64_t nLastDsq = m_mn_metaman.GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
||||||
int64_t nDsqThreshold = mmetaman->GetDsqThreshold(dmn->proTxHash, mnList.GetValidMNsCount());
|
int64_t nDsqThreshold = m_mn_metaman.GetDsqThreshold(dmn->proTxHash, mnList.GetValidMNsCount());
|
||||||
if (nLastDsq != 0 && nDsqThreshold > mmetaman->GetDsqCount()) {
|
if (nLastDsq != 0 && nDsqThreshold > m_mn_metaman.GetDsqCount()) {
|
||||||
if (fLogIPs) {
|
if (fLogIPs) {
|
||||||
LogPrint(BCLog::COINJOIN, "DSACCEPT -- last dsq too recent, must wait: peer=%d, addr=%s\n", peer.GetId(), peer.addr.ToString());
|
LogPrint(BCLog::COINJOIN, "DSACCEPT -- last dsq too recent, must wait: peer=%d, addr=%s\n", peer.GetId(), peer.addr.ToString());
|
||||||
} else {
|
} else {
|
||||||
@ -111,7 +111,7 @@ void CCoinJoinServer::ProcessDSACCEPT(CNode& peer, CDataStream& vRecv)
|
|||||||
|
|
||||||
PeerMsgRet CCoinJoinServer::ProcessDSQUEUE(const CNode& peer, CDataStream& vRecv)
|
PeerMsgRet CCoinJoinServer::ProcessDSQUEUE(const CNode& peer, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
assert(::mmetaman->IsValid());
|
assert(m_mn_metaman.IsValid());
|
||||||
|
|
||||||
CCoinJoinQueue dsq;
|
CCoinJoinQueue dsq;
|
||||||
vRecv >> dsq;
|
vRecv >> dsq;
|
||||||
@ -162,15 +162,15 @@ PeerMsgRet CCoinJoinServer::ProcessDSQUEUE(const CNode& peer, CDataStream& vRecv
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dsq.fReady) {
|
if (!dsq.fReady) {
|
||||||
int64_t nLastDsq = mmetaman->GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
int64_t nLastDsq = m_mn_metaman.GetMetaInfo(dmn->proTxHash)->GetLastDsq();
|
||||||
int64_t nDsqThreshold = mmetaman->GetDsqThreshold(dmn->proTxHash, tip_mn_list.GetValidMNsCount());
|
int64_t nDsqThreshold = m_mn_metaman.GetDsqThreshold(dmn->proTxHash, tip_mn_list.GetValidMNsCount());
|
||||||
LogPrint(BCLog::COINJOIN, "DSQUEUE -- nLastDsq: %d nDsqThreshold: %d nDsqCount: %d\n", nLastDsq, nDsqThreshold, mmetaman->GetDsqCount());
|
LogPrint(BCLog::COINJOIN, "DSQUEUE -- nLastDsq: %d nDsqThreshold: %d nDsqCount: %d\n", nLastDsq, nDsqThreshold, m_mn_metaman.GetDsqCount());
|
||||||
//don't allow a few nodes to dominate the queuing process
|
//don't allow a few nodes to dominate the queuing process
|
||||||
if (nLastDsq != 0 && nDsqThreshold > mmetaman->GetDsqCount()) {
|
if (nLastDsq != 0 && nDsqThreshold > m_mn_metaman.GetDsqCount()) {
|
||||||
LogPrint(BCLog::COINJOIN, "DSQUEUE -- Masternode %s is sending too many dsq messages\n", dmn->pdmnState->addr.ToString());
|
LogPrint(BCLog::COINJOIN, "DSQUEUE -- Masternode %s is sending too many dsq messages\n", dmn->pdmnState->addr.ToString());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
mmetaman->AllowMixing(dmn->proTxHash);
|
m_mn_metaman.AllowMixing(dmn->proTxHash);
|
||||||
|
|
||||||
LogPrint(BCLog::COINJOIN, "DSQUEUE -- new CoinJoin queue (%s) from masternode %s\n", dsq.ToString(), dmn->pdmnState->addr.ToString());
|
LogPrint(BCLog::COINJOIN, "DSQUEUE -- new CoinJoin queue (%s) from masternode %s\n", dsq.ToString(), dmn->pdmnState->addr.ToString());
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ class CCoinJoinServer;
|
|||||||
class CDataStream;
|
class CDataStream;
|
||||||
class CDeterministicMNManager;
|
class CDeterministicMNManager;
|
||||||
class CDSTXManager;
|
class CDSTXManager;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CNode;
|
class CNode;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ private:
|
|||||||
CConnman& connman;
|
CConnman& connman;
|
||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
CDSTXManager& m_dstxman;
|
CDSTXManager& m_dstxman;
|
||||||
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
CTxMemPool& mempool;
|
CTxMemPool& mempool;
|
||||||
const CActiveMasternodeManager* const m_mn_activeman;
|
const CActiveMasternodeManager* const m_mn_activeman;
|
||||||
const CMasternodeSync& m_mn_sync;
|
const CMasternodeSync& m_mn_sync;
|
||||||
@ -87,11 +89,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CCoinJoinServer(CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman, CDSTXManager& dstxman,
|
explicit CCoinJoinServer(CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman, CDSTXManager& dstxman,
|
||||||
CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync) :
|
CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman,
|
||||||
|
const CMasternodeSync& mn_sync) :
|
||||||
m_chainstate(chainstate),
|
m_chainstate(chainstate),
|
||||||
connman(_connman),
|
connman(_connman),
|
||||||
m_dmnman(dmnman),
|
m_dmnman(dmnman),
|
||||||
m_dstxman(dstxman),
|
m_dstxman(dstxman),
|
||||||
|
m_mn_metaman(mn_metaman),
|
||||||
mempool(mempool),
|
mempool(mempool),
|
||||||
m_mn_activeman(mn_activeman),
|
m_mn_activeman(mn_activeman),
|
||||||
m_mn_sync(mn_sync),
|
m_mn_sync(mn_sync),
|
||||||
|
@ -62,10 +62,10 @@ void CMNAuth::PushMNAUTH(CNode& peer, CConnman& connman, const CActiveMasternode
|
|||||||
connman.PushMessage(&peer, CNetMsgMaker(peer.GetCommonVersion()).Make(NetMsgType::MNAUTH, mnauth));
|
connman.PushMessage(&peer, CNetMsgMaker(peer.GetCommonVersion()).Make(NetMsgType::MNAUTH, mnauth));
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||||
const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv)
|
const CMasternodeSync& mn_sync, const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv)
|
||||||
{
|
{
|
||||||
assert(::mmetaman->IsValid());
|
assert(mn_metaman.IsValid());
|
||||||
|
|
||||||
if (msg_type != NetMsgType::MNAUTH || !mn_sync.IsBlockchainSynced()) {
|
if (msg_type != NetMsgType::MNAUTH || !mn_sync.IsBlockchainSynced()) {
|
||||||
// we can't verify MNAUTH messages when we don't have the latest MN list
|
// we can't verify MNAUTH messages when we don't have the latest MN list
|
||||||
@ -125,7 +125,7 @@ PeerMsgRet CMNAuth::ProcessMessage(CNode& peer, CConnman& connman, const CActive
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!peer.IsInboundConn()) {
|
if (!peer.IsInboundConn()) {
|
||||||
mmetaman->GetMetaInfo(mnauth.proRegTxHash)->SetLastOutboundSuccess(GetTime<std::chrono::seconds>().count());
|
mn_metaman.GetMetaInfo(mnauth.proRegTxHash)->SetLastOutboundSuccess(GetTime<std::chrono::seconds>().count());
|
||||||
if (peer.m_masternode_probe_connection) {
|
if (peer.m_masternode_probe_connection) {
|
||||||
LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- Masternode probe successful for %s, disconnecting. peer=%d\n",
|
LogPrint(BCLog::NET_NETCONN, "CMNAuth::ProcessMessage -- Masternode probe successful for %s, disconnecting. peer=%d\n",
|
||||||
mnauth.proRegTxHash.ToString(), peer.GetId());
|
mnauth.proRegTxHash.ToString(), peer.GetId());
|
||||||
|
@ -17,6 +17,7 @@ class CDeterministicMN;
|
|||||||
class CDeterministicMNList;
|
class CDeterministicMNList;
|
||||||
class CDeterministicMNListDiff;
|
class CDeterministicMNListDiff;
|
||||||
class CDeterministicMNManager;
|
class CDeterministicMNManager;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CMasternodeSync;
|
class CMasternodeSync;
|
||||||
class CNode;
|
class CNode;
|
||||||
|
|
||||||
@ -57,8 +58,8 @@ public:
|
|||||||
* @pre CMasternodeMetaMan's database must be successfully loaded before
|
* @pre CMasternodeMetaMan's database must be successfully loaded before
|
||||||
* attempting to call this function regardless of sync state
|
* attempting to call this function regardless of sync state
|
||||||
*/
|
*/
|
||||||
static PeerMsgRet ProcessMessage(CNode& peer, CConnman& connman, const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
static PeerMsgRet ProcessMessage(CNode& peer, CConnman& connman, CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||||
const CDeterministicMNList& tip_mn_list, std::string_view msg_type, CDataStream& vRecv);
|
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);
|
static void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,10 +43,11 @@ GovernanceStore::GovernanceStore() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CGovernanceManager::CGovernanceManager(CNetFulfilledRequestManager& netfulfilledman,
|
CGovernanceManager::CGovernanceManager(CMasternodeMetaMan& mn_metaman, CNetFulfilledRequestManager& netfulfilledman,
|
||||||
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
||||||
const std::unique_ptr<CMasternodeSync>& mn_sync) :
|
const std::unique_ptr<CMasternodeSync>& mn_sync) :
|
||||||
m_db{std::make_unique<db_type>("governance.dat", "magicGovernanceCache")},
|
m_db{std::make_unique<db_type>("governance.dat", "magicGovernanceCache")},
|
||||||
|
m_mn_metaman{mn_metaman},
|
||||||
m_netfulfilledman{netfulfilledman},
|
m_netfulfilledman{netfulfilledman},
|
||||||
m_dmnman{dmnman},
|
m_dmnman{dmnman},
|
||||||
m_mn_sync{mn_sync},
|
m_mn_sync{mn_sync},
|
||||||
@ -275,7 +276,7 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj, CConnman& c
|
|||||||
CGovernanceException e;
|
CGovernanceException e;
|
||||||
if (pairVote.second < nNow) {
|
if (pairVote.second < nNow) {
|
||||||
fRemove = true;
|
fRemove = true;
|
||||||
} else if (govobj.ProcessVote(*this, tip_mn_list, vote, e)) {
|
} else if (govobj.ProcessVote(m_mn_metaman, *this, tip_mn_list, vote, e)) {
|
||||||
vote.Relay(connman, *Assert(m_mn_sync), tip_mn_list);
|
vote.Relay(connman, *Assert(m_mn_sync), tip_mn_list);
|
||||||
fRemove = true;
|
fRemove = true;
|
||||||
}
|
}
|
||||||
@ -347,14 +348,14 @@ void CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj, CConnman
|
|||||||
|
|
||||||
void CGovernanceManager::CheckAndRemove()
|
void CGovernanceManager::CheckAndRemove()
|
||||||
{
|
{
|
||||||
assert(::mmetaman->IsValid());
|
assert(m_mn_metaman.IsValid());
|
||||||
|
|
||||||
// Return on initial sync, spammed the debug.log and provided no use
|
// Return on initial sync, spammed the debug.log and provided no use
|
||||||
if (m_mn_sync == nullptr || !m_mn_sync->IsBlockchainSynced()) return;
|
if (m_mn_sync == nullptr || !m_mn_sync->IsBlockchainSynced()) return;
|
||||||
|
|
||||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::UpdateCachesAndClean\n");
|
LogPrint(BCLog::GOBJECT, "CGovernanceManager::UpdateCachesAndClean\n");
|
||||||
|
|
||||||
std::vector<uint256> vecDirtyHashes = mmetaman->GetAndClearDirtyGovernanceObjectHashes();
|
std::vector<uint256> vecDirtyHashes = m_mn_metaman.GetAndClearDirtyGovernanceObjectHashes();
|
||||||
|
|
||||||
const auto tip_mn_list = Assert(m_dmnman)->GetListAtChainTip();
|
const auto tip_mn_list = Assert(m_dmnman)->GetListAtChainTip();
|
||||||
|
|
||||||
@ -401,7 +402,7 @@ void CGovernanceManager::CheckAndRemove()
|
|||||||
if ((pObj->IsSetCachedDelete() || pObj->IsSetExpired()) &&
|
if ((pObj->IsSetCachedDelete() || pObj->IsSetExpired()) &&
|
||||||
(nTimeSinceDeletion >= GOVERNANCE_DELETION_DELAY)) {
|
(nTimeSinceDeletion >= GOVERNANCE_DELETION_DELAY)) {
|
||||||
LogPrint(BCLog::GOBJECT, "CGovernanceManager::UpdateCachesAndClean -- erase obj %s\n", (*it).first.ToString());
|
LogPrint(BCLog::GOBJECT, "CGovernanceManager::UpdateCachesAndClean -- erase obj %s\n", (*it).first.ToString());
|
||||||
mmetaman->RemoveGovernanceObject(pObj->GetHash());
|
m_mn_metaman.RemoveGovernanceObject(pObj->GetHash());
|
||||||
|
|
||||||
// Remove vote references
|
// Remove vote references
|
||||||
const object_ref_cm_t::list_t& listItems = cmapVoteToObject.GetItemList();
|
const object_ref_cm_t::list_t& listItems = cmapVoteToObject.GetItemList();
|
||||||
@ -1123,7 +1124,7 @@ bool CGovernanceManager::ProcessVote(CNode* pfrom, const CGovernanceVote& vote,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fOk = govobj.ProcessVote(*this, Assert(m_dmnman)->GetListAtChainTip(), vote, exception) && cmapVoteToObject.Insert(nHashVote, &govobj);
|
bool fOk = govobj.ProcessVote(m_mn_metaman, *this, Assert(m_dmnman)->GetListAtChainTip(), vote, exception) && cmapVoteToObject.Insert(nHashVote, &govobj);
|
||||||
LEAVE_CRITICAL_SECTION(cs);
|
LEAVE_CRITICAL_SECTION(cs);
|
||||||
return fOk;
|
return fOk;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ class CDeterministicMNManager;
|
|||||||
class CGovernanceManager;
|
class CGovernanceManager;
|
||||||
class CGovernanceObject;
|
class CGovernanceObject;
|
||||||
class CGovernanceVote;
|
class CGovernanceVote;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CMasternodeSync;
|
class CMasternodeSync;
|
||||||
class CNetFulfilledRequestManager;
|
class CNetFulfilledRequestManager;
|
||||||
class CSporkManager;
|
class CSporkManager;
|
||||||
@ -255,6 +256,7 @@ private:
|
|||||||
const std::unique_ptr<db_type> m_db;
|
const std::unique_ptr<db_type> m_db;
|
||||||
bool is_valid{false};
|
bool is_valid{false};
|
||||||
|
|
||||||
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
CNetFulfilledRequestManager& m_netfulfilledman;
|
CNetFulfilledRequestManager& m_netfulfilledman;
|
||||||
const std::unique_ptr<CDeterministicMNManager>& m_dmnman;
|
const std::unique_ptr<CDeterministicMNManager>& m_dmnman;
|
||||||
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
|
const std::unique_ptr<CMasternodeSync>& m_mn_sync;
|
||||||
@ -271,7 +273,7 @@ private:
|
|||||||
std::map<uint256, std::shared_ptr<CSuperblock>> mapTrigger;
|
std::map<uint256, std::shared_ptr<CSuperblock>> mapTrigger;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CGovernanceManager(CNetFulfilledRequestManager& netfulfilledman,
|
explicit CGovernanceManager(CMasternodeMetaMan& mn_metaman, CNetFulfilledRequestManager& netfulfilledman,
|
||||||
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
const std::unique_ptr<CDeterministicMNManager>& dmnman,
|
||||||
const std::unique_ptr<CMasternodeSync>& mn_sync);
|
const std::unique_ptr<CMasternodeSync>& mn_sync);
|
||||||
~CGovernanceManager();
|
~CGovernanceManager();
|
||||||
|
@ -80,9 +80,10 @@ CGovernanceObject::CGovernanceObject(const CGovernanceObject& other) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGovernanceObject::ProcessVote(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, const CGovernanceVote& vote, CGovernanceException& exception)
|
bool CGovernanceObject::ProcessVote(CMasternodeMetaMan& mn_metaman, CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list,
|
||||||
|
const CGovernanceVote& vote, CGovernanceException& exception)
|
||||||
{
|
{
|
||||||
assert(::mmetaman->IsValid());
|
assert(mn_metaman.IsValid());
|
||||||
|
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ bool CGovernanceObject::ProcessVote(CGovernanceManager& govman, const CDetermini
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mmetaman->AddGovernanceVote(dmn->proTxHash, vote.GetParentHash())) {
|
if (!mn_metaman.AddGovernanceVote(dmn->proTxHash, vote.GetParentHash())) {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << "CGovernanceObject::ProcessVote -- Unable to add governance vote"
|
ostr << "CGovernanceObject::ProcessVote -- Unable to add governance vote"
|
||||||
<< ", MN outpoint = " << vote.GetMasternodeOutpoint().ToStringShort()
|
<< ", MN outpoint = " << vote.GetMasternodeOutpoint().ToStringShort()
|
||||||
|
@ -19,6 +19,7 @@ class CDeterministicMNList;
|
|||||||
class CGovernanceManager;
|
class CGovernanceManager;
|
||||||
class CGovernanceObject;
|
class CGovernanceObject;
|
||||||
class CGovernanceVote;
|
class CGovernanceVote;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CMasternodeSync;
|
class CMasternodeSync;
|
||||||
class CNode;
|
class CNode;
|
||||||
|
|
||||||
@ -290,7 +291,8 @@ public:
|
|||||||
void LoadData();
|
void LoadData();
|
||||||
void GetData(UniValue& objResult) const;
|
void GetData(UniValue& objResult) const;
|
||||||
|
|
||||||
bool ProcessVote(CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list, const CGovernanceVote& vote, CGovernanceException& exception);
|
bool ProcessVote(CMasternodeMetaMan& mn_metaman, CGovernanceManager& govman, const CDeterministicMNList& tip_mn_list,
|
||||||
|
const CGovernanceVote& vote, CGovernanceException& exception);
|
||||||
|
|
||||||
/// Called when MN's which have voted on this object have been removed
|
/// Called when MN's which have voted on this object have been removed
|
||||||
void ClearMasternodeVotes(const CDeterministicMNList& tip_mn_list);
|
void ClearMasternodeVotes(const CDeterministicMNList& tip_mn_list);
|
||||||
|
16
src/init.cpp
16
src/init.cpp
@ -309,8 +309,7 @@ void PrepareShutdown(NodeContext& node)
|
|||||||
node.sporkman.reset();
|
node.sporkman.reset();
|
||||||
node.govman.reset();
|
node.govman.reset();
|
||||||
node.netfulfilledman.reset();
|
node.netfulfilledman.reset();
|
||||||
node.mn_metaman = nullptr;
|
node.mn_metaman.reset();
|
||||||
::mmetaman.reset();
|
|
||||||
|
|
||||||
// Stop and delete all indexes only after flushing background callbacks.
|
// Stop and delete all indexes only after flushing background callbacks.
|
||||||
if (g_txindex) {
|
if (g_txindex) {
|
||||||
@ -1677,15 +1676,14 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
|||||||
node.chainman = &g_chainman;
|
node.chainman = &g_chainman;
|
||||||
ChainstateManager& chainman = *Assert(node.chainman);
|
ChainstateManager& chainman = *Assert(node.chainman);
|
||||||
|
|
||||||
assert(!::mmetaman);
|
assert(!node.mn_metaman);
|
||||||
::mmetaman = std::make_unique<CMasternodeMetaMan>();
|
node.mn_metaman = std::make_unique<CMasternodeMetaMan>();
|
||||||
node.mn_metaman = ::mmetaman.get();
|
|
||||||
|
|
||||||
assert(!node.netfulfilledman);
|
assert(!node.netfulfilledman);
|
||||||
node.netfulfilledman = std::make_unique<CNetFulfilledRequestManager>();
|
node.netfulfilledman = std::make_unique<CNetFulfilledRequestManager>();
|
||||||
|
|
||||||
assert(!node.govman);
|
assert(!node.govman);
|
||||||
node.govman = std::make_unique<CGovernanceManager>(*node.netfulfilledman, ::deterministicMNManager, node.mn_sync);
|
node.govman = std::make_unique<CGovernanceManager>(*node.mn_metaman, *node.netfulfilledman, ::deterministicMNManager, node.mn_sync);
|
||||||
|
|
||||||
assert(!node.sporkman);
|
assert(!node.sporkman);
|
||||||
node.sporkman = std::make_unique<CSporkManager>();
|
node.sporkman = std::make_unique<CSporkManager>();
|
||||||
@ -1958,7 +1956,7 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
|||||||
node.llmq_ctx->Stop();
|
node.llmq_ctx->Stop();
|
||||||
}
|
}
|
||||||
node.llmq_ctx.reset();
|
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.llmq_ctx = std::make_unique<LLMQContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman,
|
||||||
*node.mempool, node.mn_activeman.get(), *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
|
// Have to start it early to let VerifyDB check ChainLock signatures in coinbase
|
||||||
node.llmq_ctx->Start();
|
node.llmq_ctx->Start();
|
||||||
@ -2204,8 +2202,8 @@ bool AppInitMain(const CoreContext& context, NodeContext& node, interfaces::Bloc
|
|||||||
|
|
||||||
// ********************************************************* Step 7c: Setup CoinJoin
|
// ********************************************************* Step 7c: Setup CoinJoin
|
||||||
|
|
||||||
node.cj_ctx = std::make_unique<CJContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.mempool, node.mn_activeman.get(),
|
node.cj_ctx = std::make_unique<CJContext>(chainman.ActiveChainstate(), *node.connman, *node.dmnman, *node.mn_metaman, *node.mempool,
|
||||||
*node.mn_sync, !ignores_incoming_txs);
|
node.mn_activeman.get(), *node.mn_sync, !ignores_incoming_txs);
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(*node.cj_ctx->walletman);
|
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(*node.cj_ctx->walletman);
|
||||||
|
@ -20,8 +20,9 @@
|
|||||||
#include <masternode/sync.h>
|
#include <masternode/sync.h>
|
||||||
|
|
||||||
LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
||||||
CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman,
|
CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool,
|
||||||
const CMasternodeSync& mn_sync, const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe) :
|
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||||
|
const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe) :
|
||||||
bls_worker{std::make_shared<CBLSWorker>()},
|
bls_worker{std::make_shared<CBLSWorker>()},
|
||||||
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
|
dkg_debugman{std::make_unique<llmq::CDKGDebugManager>()},
|
||||||
quorum_block_processor{[&]() -> llmq::CQuorumBlockProcessor* const {
|
quorum_block_processor{[&]() -> llmq::CQuorumBlockProcessor* const {
|
||||||
@ -29,7 +30,7 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis
|
|||||||
llmq::quorumBlockProcessor = std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, connman, dmnman, evo_db);
|
llmq::quorumBlockProcessor = std::make_unique<llmq::CQuorumBlockProcessor>(chainstate, connman, dmnman, evo_db);
|
||||||
return llmq::quorumBlockProcessor.get();
|
return llmq::quorumBlockProcessor.get();
|
||||||
}()},
|
}()},
|
||||||
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, dmnman, *dkg_debugman, *quorum_block_processor, mn_activeman, sporkman, unit_tests, wipe)},
|
qdkgsman{std::make_unique<llmq::CDKGSessionManager>(*bls_worker, chainstate, connman, dmnman, *dkg_debugman, mn_metaman, *quorum_block_processor, mn_activeman, sporkman, unit_tests, wipe)},
|
||||||
qman{[&]() -> llmq::CQuorumManager* const {
|
qman{[&]() -> llmq::CQuorumManager* const {
|
||||||
assert(llmq::quorumManager == nullptr);
|
assert(llmq::quorumManager == nullptr);
|
||||||
llmq::quorumManager = std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, dmnman, *qdkgsman, evo_db, *quorum_block_processor, mn_activeman, mn_sync, sporkman);
|
llmq::quorumManager = std::make_unique<llmq::CQuorumManager>(*bls_worker, chainstate, connman, dmnman, *qdkgsman, evo_db, *quorum_block_processor, mn_activeman, mn_sync, sporkman);
|
||||||
|
@ -14,6 +14,7 @@ class CConnman;
|
|||||||
class CDeterministicMNManager;
|
class CDeterministicMNManager;
|
||||||
class CDBWrapper;
|
class CDBWrapper;
|
||||||
class CEvoDB;
|
class CEvoDB;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CMasternodeSync;
|
class CMasternodeSync;
|
||||||
class CMNHFManager;
|
class CMNHFManager;
|
||||||
class CSporkManager;
|
class CSporkManager;
|
||||||
@ -36,8 +37,9 @@ struct LLMQContext {
|
|||||||
LLMQContext() = delete;
|
LLMQContext() = delete;
|
||||||
LLMQContext(const LLMQContext&) = delete;
|
LLMQContext(const LLMQContext&) = delete;
|
||||||
LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
LLMQContext(CChainState& chainstate, CConnman& connman, CDeterministicMNManager& dmnman, CEvoDB& evo_db,
|
||||||
CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool, const CActiveMasternodeManager* const mn_activeman,
|
CMasternodeMetaMan& mn_metaman, CMNHFManager& mnhfman, CSporkManager& sporkman, CTxMemPool& mempool,
|
||||||
const CMasternodeSync& mn_sync, const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe);
|
const CActiveMasternodeManager* const mn_activeman, const CMasternodeSync& mn_sync,
|
||||||
|
const std::unique_ptr<PeerManager>& peerman, bool unit_tests, bool wipe);
|
||||||
~LLMQContext();
|
~LLMQContext();
|
||||||
|
|
||||||
void Interrupt();
|
void Interrupt();
|
||||||
|
@ -450,7 +450,7 @@ void CDKGSession::VerifyAndComplain(CDKGPendingMessages& pendingMessages)
|
|||||||
|
|
||||||
void CDKGSession::VerifyConnectionAndMinProtoVersions() const
|
void CDKGSession::VerifyConnectionAndMinProtoVersions() const
|
||||||
{
|
{
|
||||||
assert(::mmetaman->IsValid());
|
assert(m_mn_metaman.IsValid());
|
||||||
|
|
||||||
if (!IsQuorumPoseEnabled(params.type, m_sporkman)) {
|
if (!IsQuorumPoseEnabled(params.type, m_sporkman)) {
|
||||||
return;
|
return;
|
||||||
@ -482,7 +482,7 @@ void CDKGSession::VerifyConnectionAndMinProtoVersions() const
|
|||||||
logger.Batch("%s does not have min proto version %d (has %d)", m->dmn->proTxHash.ToString(), MIN_MASTERNODE_PROTO_VERSION, it->second);
|
logger.Batch("%s does not have min proto version %d (has %d)", m->dmn->proTxHash.ToString(), MIN_MASTERNODE_PROTO_VERSION, it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mmetaman->GetMetaInfo(m->dmn->proTxHash)->OutboundFailedTooManyTimes()) {
|
if (m_mn_metaman.GetMetaInfo(m->dmn->proTxHash)->OutboundFailedTooManyTimes()) {
|
||||||
m->badConnection = true;
|
m->badConnection = true;
|
||||||
logger.Batch("%s failed to connect to it too many times", m->dmn->proTxHash.ToString());
|
logger.Batch("%s failed to connect to it too many times", m->dmn->proTxHash.ToString());
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ class CActiveMasternodeManager;
|
|||||||
class CInv;
|
class CInv;
|
||||||
class CConnman;
|
class CConnman;
|
||||||
class CDeterministicMN;
|
class CDeterministicMN;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CSporkManager;
|
class CSporkManager;
|
||||||
class UniValue;
|
class UniValue;
|
||||||
|
|
||||||
@ -272,9 +273,11 @@ private:
|
|||||||
|
|
||||||
CBLSWorker& blsWorker;
|
CBLSWorker& blsWorker;
|
||||||
CBLSWorkerCache cache;
|
CBLSWorkerCache cache;
|
||||||
|
CConnman& connman;
|
||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
CDKGSessionManager& dkgManager;
|
CDKGSessionManager& dkgManager;
|
||||||
CDKGDebugManager& dkgDebugManager;
|
CDKGDebugManager& dkgDebugManager;
|
||||||
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
const CActiveMasternodeManager* const m_mn_activeman;
|
const CActiveMasternodeManager* const m_mn_activeman;
|
||||||
const CSporkManager& m_sporkman;
|
const CSporkManager& m_sporkman;
|
||||||
|
|
||||||
@ -297,7 +300,6 @@ private:
|
|||||||
|
|
||||||
uint256 myProTxHash;
|
uint256 myProTxHash;
|
||||||
CBLSId myId;
|
CBLSId myId;
|
||||||
CConnman& connman;
|
|
||||||
std::optional<size_t> myIdx;
|
std::optional<size_t> myIdx;
|
||||||
|
|
||||||
// all indexed by msg hash
|
// all indexed by msg hash
|
||||||
@ -317,11 +319,12 @@ private:
|
|||||||
std::set<uint256> validCommitments GUARDED_BY(invCs);
|
std::set<uint256> validCommitments GUARDED_BY(invCs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDKGSession(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CDeterministicMNManager& dmnman,
|
CDKGSession(const Consensus::LLMQParams& _params, CBLSWorker& _blsWorker, CConnman& _connman,
|
||||||
CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager, CConnman& _connman,
|
CDeterministicMNManager& dmnman, CDKGSessionManager& _dkgManager, CDKGDebugManager& _dkgDebugManager,
|
||||||
const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman) :
|
CMasternodeMetaMan& mn_metaman, const CActiveMasternodeManager* const mn_activeman,
|
||||||
params(_params), blsWorker(_blsWorker), cache(_blsWorker), m_dmnman(dmnman), dkgManager(_dkgManager),
|
const CSporkManager& sporkman) :
|
||||||
dkgDebugManager(_dkgDebugManager), m_mn_activeman(mn_activeman), m_sporkman(sporkman), connman(_connman) {}
|
params(_params), blsWorker(_blsWorker), cache(_blsWorker), connman(_connman), m_dmnman(dmnman), dkgManager(_dkgManager),
|
||||||
|
dkgDebugManager(_dkgDebugManager), m_mn_metaman(mn_metaman), m_mn_activeman(mn_activeman), m_sporkman(sporkman) {}
|
||||||
|
|
||||||
bool Init(gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, Span<CDeterministicMNCPtr> mns, const uint256& _myProTxHash, int _quorumIndex);
|
bool Init(gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, Span<CDeterministicMNCPtr> mns, const uint256& _myProTxHash, int _quorumIndex);
|
||||||
|
|
||||||
|
@ -25,21 +25,22 @@ namespace llmq
|
|||||||
{
|
{
|
||||||
|
|
||||||
CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
CDKGSessionHandler::CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor,
|
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CMasternodeMetaMan& mn_metaman,
|
||||||
const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman, const Consensus::LLMQParams& _params,
|
CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* const mn_activeman,
|
||||||
int _quorumIndex) :
|
const CSporkManager& sporkman, const Consensus::LLMQParams& _params, int _quorumIndex) :
|
||||||
blsWorker(_blsWorker),
|
blsWorker(_blsWorker),
|
||||||
m_chainstate(chainstate),
|
m_chainstate(chainstate),
|
||||||
connman(_connman),
|
connman(_connman),
|
||||||
m_dmnman(dmnman),
|
m_dmnman(dmnman),
|
||||||
dkgDebugManager(_dkgDebugManager),
|
dkgDebugManager(_dkgDebugManager),
|
||||||
dkgManager(_dkgManager),
|
dkgManager(_dkgManager),
|
||||||
|
m_mn_metaman(mn_metaman),
|
||||||
quorumBlockProcessor(_quorumBlockProcessor),
|
quorumBlockProcessor(_quorumBlockProcessor),
|
||||||
m_mn_activeman(mn_activeman),
|
m_mn_activeman(mn_activeman),
|
||||||
m_sporkman(sporkman),
|
m_sporkman(sporkman),
|
||||||
params(_params),
|
params(_params),
|
||||||
quorumIndex(_quorumIndex),
|
quorumIndex(_quorumIndex),
|
||||||
curSession(std::make_unique<CDKGSession>(_params, _blsWorker, dmnman, _dkgManager, _dkgDebugManager, _connman, m_mn_activeman, sporkman)),
|
curSession(std::make_unique<CDKGSession>(_params, _blsWorker, _connman, dmnman, _dkgManager, _dkgDebugManager, m_mn_metaman, m_mn_activeman, sporkman)),
|
||||||
pendingContributions((size_t)_params.size * 2, MSG_QUORUM_CONTRIB), // we allow size*2 messages as we need to make sure we see bad behavior (double messages)
|
pendingContributions((size_t)_params.size * 2, MSG_QUORUM_CONTRIB), // we allow size*2 messages as we need to make sure we see bad behavior (double messages)
|
||||||
pendingComplaints((size_t)_params.size * 2, MSG_QUORUM_COMPLAINT),
|
pendingComplaints((size_t)_params.size * 2, MSG_QUORUM_COMPLAINT),
|
||||||
pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION),
|
pendingJustifications((size_t)_params.size * 2, MSG_QUORUM_JUSTIFICATION),
|
||||||
@ -187,7 +188,7 @@ void CDKGSessionHandler::StopThread()
|
|||||||
|
|
||||||
bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
|
bool CDKGSessionHandler::InitNewQuorum(const CBlockIndex* pQuorumBaseBlockIndex)
|
||||||
{
|
{
|
||||||
curSession = std::make_unique<CDKGSession>(params, blsWorker, m_dmnman, dkgManager, dkgDebugManager, connman, m_mn_activeman, m_sporkman);
|
curSession = std::make_unique<CDKGSession>(params, blsWorker, connman, m_dmnman, dkgManager, dkgDebugManager, m_mn_metaman, m_mn_activeman, m_sporkman);
|
||||||
|
|
||||||
if (!DeploymentDIP0003Enforced(pQuorumBaseBlockIndex->nHeight, Params().GetConsensus())) {
|
if (!DeploymentDIP0003Enforced(pQuorumBaseBlockIndex->nHeight, Params().GetConsensus())) {
|
||||||
return false;
|
return false;
|
||||||
@ -533,7 +534,7 @@ void CDKGSessionHandler::HandleDKGRound()
|
|||||||
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
const auto tip_mn_list = m_dmnman.GetListAtChainTip();
|
||||||
utils::EnsureQuorumConnections(params, connman, m_dmnman, m_sporkman, tip_mn_list, pQuorumBaseBlockIndex, curSession->myProTxHash);
|
utils::EnsureQuorumConnections(params, connman, m_dmnman, m_sporkman, tip_mn_list, pQuorumBaseBlockIndex, curSession->myProTxHash);
|
||||||
if (curSession->AreWeMember()) {
|
if (curSession->AreWeMember()) {
|
||||||
utils::AddQuorumProbeConnections(params, connman, m_dmnman, m_sporkman, tip_mn_list, pQuorumBaseBlockIndex, curSession->myProTxHash);
|
utils::AddQuorumProbeConnections(params, connman, m_dmnman, m_mn_metaman, m_sporkman, tip_mn_list, pQuorumBaseBlockIndex, curSession->myProTxHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitForNextPhase(QuorumPhase::Initialized, QuorumPhase::Contribute, curQuorumHash);
|
WaitForNextPhase(QuorumPhase::Initialized, QuorumPhase::Contribute, curQuorumHash);
|
||||||
|
@ -19,6 +19,7 @@ class CBlockIndex;
|
|||||||
class CBLSWorker;
|
class CBLSWorker;
|
||||||
class CChainState;
|
class CChainState;
|
||||||
class CDeterministicMNManager;
|
class CDeterministicMNManager;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CSporkManager;
|
class CSporkManager;
|
||||||
class PeerManager;
|
class PeerManager;
|
||||||
|
|
||||||
@ -125,6 +126,7 @@ private:
|
|||||||
CDeterministicMNManager& m_dmnman;
|
CDeterministicMNManager& m_dmnman;
|
||||||
CDKGDebugManager& dkgDebugManager;
|
CDKGDebugManager& dkgDebugManager;
|
||||||
CDKGSessionManager& dkgManager;
|
CDKGSessionManager& dkgManager;
|
||||||
|
CMasternodeMetaMan& m_mn_metaman;
|
||||||
CQuorumBlockProcessor& quorumBlockProcessor;
|
CQuorumBlockProcessor& quorumBlockProcessor;
|
||||||
const CActiveMasternodeManager* const m_mn_activeman;
|
const CActiveMasternodeManager* const m_mn_activeman;
|
||||||
const CSporkManager& m_sporkman;
|
const CSporkManager& m_sporkman;
|
||||||
@ -147,9 +149,9 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
CDKGSessionHandler(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CQuorumBlockProcessor& _quorumBlockProcessor,
|
CDKGDebugManager& _dkgDebugManager, CDKGSessionManager& _dkgManager, CMasternodeMetaMan& mn_metaman,
|
||||||
const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman, const Consensus::LLMQParams& _params,
|
CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* const mn_activeman,
|
||||||
int _quorumIndex);
|
const CSporkManager& sporkman, const Consensus::LLMQParams& _params, int _quorumIndex);
|
||||||
~CDKGSessionHandler() = default;
|
~CDKGSessionHandler() = default;
|
||||||
|
|
||||||
void UpdatedBlockTip(const CBlockIndex *pindexNew);
|
void UpdatedBlockTip(const CBlockIndex *pindexNew);
|
||||||
|
@ -25,8 +25,8 @@ static const std::string DB_SKCONTRIB = "qdkg_S";
|
|||||||
static const std::string DB_ENC_CONTRIB = "qdkg_E";
|
static const std::string DB_ENC_CONTRIB = "qdkg_E";
|
||||||
|
|
||||||
CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CDKGDebugManager& _dkgDebugManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* const mn_activeman,
|
CDKGDebugManager& _dkgDebugManager, CMasternodeMetaMan& mn_metaman, CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||||
const CSporkManager& sporkman, bool unitTests, bool fWipe) :
|
const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman, bool unitTests, bool fWipe) :
|
||||||
db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/dkgdb"), 1 << 20, unitTests, fWipe)),
|
db(std::make_unique<CDBWrapper>(unitTests ? "" : (GetDataDir() / "llmq/dkgdb"), 1 << 20, unitTests, fWipe)),
|
||||||
blsWorker(_blsWorker),
|
blsWorker(_blsWorker),
|
||||||
m_chainstate(chainstate),
|
m_chainstate(chainstate),
|
||||||
@ -49,7 +49,7 @@ CDKGSessionManager::CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chai
|
|||||||
for (const auto i : irange::range(session_count)) {
|
for (const auto i : irange::range(session_count)) {
|
||||||
dkgSessionHandlers.emplace(std::piecewise_construct,
|
dkgSessionHandlers.emplace(std::piecewise_construct,
|
||||||
std::forward_as_tuple(params.type, i),
|
std::forward_as_tuple(params.type, i),
|
||||||
std::forward_as_tuple(blsWorker, m_chainstate, connman, dmnman, dkgDebugManager, *this, quorumBlockProcessor, mn_activeman, spork_manager, params, i));
|
std::forward_as_tuple(blsWorker, m_chainstate, connman, dmnman, dkgDebugManager, *this, mn_metaman, quorumBlockProcessor, mn_activeman, spork_manager, params, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ class CChainState;
|
|||||||
class CDBWrapper;
|
class CDBWrapper;
|
||||||
class CDeterministicMNManager;
|
class CDeterministicMNManager;
|
||||||
class CDKGDebugManager;
|
class CDKGDebugManager;
|
||||||
|
class CMasternodeMetaMan;
|
||||||
class CSporkManager;
|
class CSporkManager;
|
||||||
class PeerManager;
|
class PeerManager;
|
||||||
|
|
||||||
@ -67,8 +68,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
CDKGSessionManager(CBLSWorker& _blsWorker, CChainState& chainstate, CConnman& _connman, CDeterministicMNManager& dmnman,
|
||||||
CDKGDebugManager& _dkgDebugManager, CQuorumBlockProcessor& _quorumBlockProcessor, const CActiveMasternodeManager* const mn_activeman,
|
CDKGDebugManager& _dkgDebugManager, CMasternodeMetaMan& mn_metaman, CQuorumBlockProcessor& _quorumBlockProcessor,
|
||||||
const CSporkManager& sporkman, bool unitTests, bool fWipe);
|
const CActiveMasternodeManager* const mn_activeman, const CSporkManager& sporkman, bool unitTests, bool fWipe);
|
||||||
~CDKGSessionManager() = default;
|
~CDKGSessionManager() = default;
|
||||||
|
|
||||||
void StartThreads();
|
void StartThreads();
|
||||||
|
@ -808,11 +808,11 @@ bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, CConnman&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, CDeterministicMNManager& dmnman, const CSporkManager& sporkman,
|
void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, CDeterministicMNManager& dmnman,
|
||||||
const CDeterministicMNList& tip_mn_list, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex,
|
CMasternodeMetaMan& mn_metaman, const CSporkManager& sporkman, const CDeterministicMNList& tip_mn_list,
|
||||||
const uint256 &myProTxHash)
|
gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256 &myProTxHash)
|
||||||
{
|
{
|
||||||
assert(::mmetaman->IsValid());
|
assert(mn_metaman.IsValid());
|
||||||
|
|
||||||
if (!IsQuorumPoseEnabled(llmqParams.type, sporkman)) {
|
if (!IsQuorumPoseEnabled(llmqParams.type, sporkman)) {
|
||||||
return;
|
return;
|
||||||
@ -826,7 +826,7 @@ void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, CConnman
|
|||||||
if (dmn->proTxHash == myProTxHash) {
|
if (dmn->proTxHash == myProTxHash) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto lastOutbound = mmetaman->GetMetaInfo(dmn->proTxHash)->GetLastOutboundSuccess();
|
auto lastOutbound = mn_metaman.GetMetaInfo(dmn->proTxHash)->GetLastOutboundSuccess();
|
||||||
if (curTime - lastOutbound < 10 * 60) {
|
if (curTime - lastOutbound < 10 * 60) {
|
||||||
// avoid re-probing nodes too often
|
// avoid re-probing nodes too often
|
||||||
continue;
|
continue;
|
||||||
|
@ -19,9 +19,11 @@ class CBlockIndex;
|
|||||||
class CDeterministicMN;
|
class CDeterministicMN;
|
||||||
class CDeterministicMNList;
|
class CDeterministicMNList;
|
||||||
class CDeterministicMNManager;
|
class CDeterministicMNManager;
|
||||||
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;
|
class CMasternodeMetaMan;
|
||||||
class CSporkManager;
|
class CSporkManager;
|
||||||
|
|
||||||
|
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;
|
||||||
|
|
||||||
namespace llmq
|
namespace llmq
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -39,9 +41,9 @@ std::set<size_t> CalcDeterministicWatchConnections(Consensus::LLMQType llmqType,
|
|||||||
bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, CDeterministicMNManager& dmnman, const CSporkManager& sporkman,
|
bool EnsureQuorumConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, CDeterministicMNManager& dmnman, const CSporkManager& sporkman,
|
||||||
const CDeterministicMNList& tip_mn_list, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex,
|
const CDeterministicMNList& tip_mn_list, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex,
|
||||||
const uint256& myProTxHash);
|
const uint256& myProTxHash);
|
||||||
void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, CDeterministicMNManager& dmnman, const CSporkManager& sporkman,
|
void AddQuorumProbeConnections(const Consensus::LLMQParams& llmqParams, CConnman& connman, CDeterministicMNManager& dmnman,
|
||||||
const CDeterministicMNList& tip_mn_list, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex,
|
CMasternodeMetaMan& mn_metaman, const CSporkManager& sporkman, const CDeterministicMNList& tip_mn_list,
|
||||||
const uint256& myProTxHash);
|
gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, const uint256& myProTxHash);
|
||||||
|
|
||||||
template <typename CacheType>
|
template <typename CacheType>
|
||||||
void InitQuorumsCache(CacheType& cache, bool limit_by_connections = true);
|
void InitQuorumsCache(CacheType& cache, bool limit_by_connections = true);
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
std::unique_ptr<CMasternodeMetaMan> mmetaman;
|
|
||||||
|
|
||||||
const std::string MasternodeMetaStore::SERIALIZATION_VERSION_STRING = "CMasternodeMetaMan-Version-3";
|
const std::string MasternodeMetaStore::SERIALIZATION_VERSION_STRING = "CMasternodeMetaMan-Version-3";
|
||||||
|
|
||||||
CMasternodeMetaMan::CMasternodeMetaMan() :
|
CMasternodeMetaMan::CMasternodeMetaMan() :
|
||||||
|
@ -176,6 +176,4 @@ public:
|
|||||||
std::vector<uint256> GetAndClearDirtyGovernanceObjectHashes();
|
std::vector<uint256> GetAndClearDirtyGovernanceObjectHashes();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::unique_ptr<CMasternodeMetaMan> mmetaman;
|
|
||||||
|
|
||||||
#endif // BITCOIN_MASTERNODE_META_H
|
#endif // BITCOIN_MASTERNODE_META_H
|
||||||
|
@ -4630,7 +4630,7 @@ void PeerManagerImpl::ProcessMessage(
|
|||||||
ProcessPeerMsgRet(m_sporkman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(m_sporkman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
|
||||||
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
|
m_mn_sync.ProcessMessage(pfrom, msg_type, vRecv);
|
||||||
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(m_govman.ProcessMessage(pfrom, m_connman, msg_type, vRecv), pfrom);
|
||||||
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, m_connman, m_mn_activeman, m_mn_sync, m_dmnman->GetListAtChainTip(), msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(CMNAuth::ProcessMessage(pfrom, m_connman, m_mn_metaman, 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->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->qdkgsman->ProcessMessage(pfrom, this, msg_type, vRecv), pfrom);
|
||||||
ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
ProcessPeerMsgRet(m_llmq_ctx->qman->ProcessMessage(pfrom, msg_type, vRecv), pfrom);
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <interfaces/chain.h>
|
#include <interfaces/chain.h>
|
||||||
#include <interfaces/coinjoin.h>
|
#include <interfaces/coinjoin.h>
|
||||||
#include <llmq/context.h>
|
#include <llmq/context.h>
|
||||||
|
#include <masternode/meta.h>
|
||||||
#include <masternode/node.h>
|
#include <masternode/node.h>
|
||||||
#include <masternode/sync.h>
|
#include <masternode/sync.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
|
@ -77,13 +77,13 @@ struct NodeContext {
|
|||||||
std::unique_ptr<CChainstateHelper> chain_helper;
|
std::unique_ptr<CChainstateHelper> chain_helper;
|
||||||
std::unique_ptr<CGovernanceManager> govman;
|
std::unique_ptr<CGovernanceManager> govman;
|
||||||
std::unique_ptr<CJContext> cj_ctx;
|
std::unique_ptr<CJContext> cj_ctx;
|
||||||
|
std::unique_ptr<CMasternodeMetaMan> mn_metaman;
|
||||||
std::unique_ptr<CMasternodeSync> mn_sync;
|
std::unique_ptr<CMasternodeSync> mn_sync;
|
||||||
std::unique_ptr<CMNHFManager> mnhf_manager;
|
std::unique_ptr<CMNHFManager> mnhf_manager;
|
||||||
std::unique_ptr<CNetFulfilledRequestManager> netfulfilledman;
|
std::unique_ptr<CNetFulfilledRequestManager> netfulfilledman;
|
||||||
std::unique_ptr<CSporkManager> sporkman;
|
std::unique_ptr<CSporkManager> sporkman;
|
||||||
std::unique_ptr<LLMQContext> llmq_ctx;
|
std::unique_ptr<LLMQContext> llmq_ctx;
|
||||||
CDeterministicMNManager* dmnman{nullptr};
|
CDeterministicMNManager* dmnman{nullptr};
|
||||||
CMasternodeMetaMan* mn_metaman{nullptr};
|
|
||||||
|
|
||||||
//! Declare default constructor and destructor that are not inline, so code
|
//! Declare default constructor and destructor that are not inline, so code
|
||||||
//! instantiating the NodeContext struct doesn't need to #include class
|
//! instantiating the NodeContext struct doesn't need to #include class
|
||||||
|
@ -111,11 +111,12 @@ void DashTestSetup(NodeContext& node, const CChainParams& chainparams)
|
|||||||
|
|
||||||
::deterministicMNManager = std::make_unique<CDeterministicMNManager>(chainstate, *node.connman, *node.evodb);
|
::deterministicMNManager = std::make_unique<CDeterministicMNManager>(chainstate, *node.connman, *node.evodb);
|
||||||
node.dmnman = ::deterministicMNManager.get();
|
node.dmnman = ::deterministicMNManager.get();
|
||||||
node.cj_ctx = std::make_unique<CJContext>(chainstate, *node.connman, *node.dmnman, *node.mempool, /* mn_activeman = */ nullptr, *node.mn_sync, /* relay_txes = */ true);
|
node.cj_ctx = std::make_unique<CJContext>(chainstate, *node.connman, *node.dmnman, *node.mn_metaman, *node.mempool,
|
||||||
|
/* mn_activeman = */ nullptr, *node.mn_sync, /* relay_txes = */ true);
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(*node.cj_ctx->walletman);
|
node.coinjoin_loader = interfaces::MakeCoinJoinLoader(*node.cj_ctx->walletman);
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
node.llmq_ctx = std::make_unique<LLMQContext>(chainstate, *node.connman, *node.dmnman, *node.evodb, *node.mnhf_manager, *node.sporkman, *node.mempool,
|
node.llmq_ctx = std::make_unique<LLMQContext>(chainstate, *node.connman, *node.dmnman, *node.evodb, *node.mn_metaman, *node.mnhf_manager, *node.sporkman, *node.mempool,
|
||||||
/* mn_activeman = */ nullptr, *node.mn_sync, node.peerman, /* unit_tests = */ true, /* wipe = */ false);
|
/* mn_activeman = */ nullptr, *node.mn_sync, node.peerman, /* unit_tests = */ true, /* wipe = */ false);
|
||||||
node.chain_helper = std::make_unique<CChainstateHelper>(*node.cpoolman, *node.dmnman, *node.mnhf_manager, *node.govman, *(node.llmq_ctx->quorum_block_processor),
|
node.chain_helper = std::make_unique<CChainstateHelper>(*node.cpoolman, *node.dmnman, *node.mnhf_manager, *node.govman, *(node.llmq_ctx->quorum_block_processor),
|
||||||
chainparams.GetConsensus(), *node.mn_sync, *node.sporkman, *(node.llmq_ctx->clhandler));
|
chainparams.GetConsensus(), *node.mn_sync, *node.sporkman, *(node.llmq_ctx->clhandler));
|
||||||
@ -227,11 +228,10 @@ ChainTestingSetup::ChainTestingSetup(const std::string& chainName, const std::ve
|
|||||||
|
|
||||||
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
|
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
|
||||||
|
|
||||||
::mmetaman = std::make_unique<CMasternodeMetaMan>();
|
m_node.mn_metaman = std::make_unique<CMasternodeMetaMan>();
|
||||||
m_node.mn_metaman = ::mmetaman.get();
|
|
||||||
m_node.netfulfilledman = std::make_unique<CNetFulfilledRequestManager>();
|
m_node.netfulfilledman = std::make_unique<CNetFulfilledRequestManager>();
|
||||||
m_node.sporkman = std::make_unique<CSporkManager>();
|
m_node.sporkman = std::make_unique<CSporkManager>();
|
||||||
m_node.govman = std::make_unique<CGovernanceManager>(*m_node.netfulfilledman, ::deterministicMNManager, m_node.mn_sync);
|
m_node.govman = std::make_unique<CGovernanceManager>(*m_node.mn_metaman, *m_node.netfulfilledman, ::deterministicMNManager, m_node.mn_sync);
|
||||||
m_node.mn_sync = std::make_unique<CMasternodeSync>(*m_node.connman, *m_node.netfulfilledman, *m_node.govman);
|
m_node.mn_sync = std::make_unique<CMasternodeSync>(*m_node.connman, *m_node.netfulfilledman, *m_node.govman);
|
||||||
|
|
||||||
// Start script-checking threads. Set g_parallel_script_checks to true so they are used.
|
// Start script-checking threads. Set g_parallel_script_checks to true so they are used.
|
||||||
@ -250,8 +250,7 @@ ChainTestingSetup::~ChainTestingSetup()
|
|||||||
m_node.govman.reset();
|
m_node.govman.reset();
|
||||||
m_node.sporkman.reset();
|
m_node.sporkman.reset();
|
||||||
m_node.netfulfilledman.reset();
|
m_node.netfulfilledman.reset();
|
||||||
m_node.mn_metaman = nullptr;
|
m_node.mn_metaman.reset();
|
||||||
::mmetaman.reset();
|
|
||||||
m_node.connman.reset();
|
m_node.connman.reset();
|
||||||
m_node.addrman.reset();
|
m_node.addrman.reset();
|
||||||
m_node.args = nullptr;
|
m_node.args = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user