refactor: move CConnman out of CoinJoinWalletManager ctor

This commit is contained in:
Kittywhiskers Van Gogh 2024-12-04 18:19:51 +00:00
parent ac930a84d8
commit 953ba96ac9
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
4 changed files with 8 additions and 10 deletions

View File

@ -1917,11 +1917,11 @@ void CoinJoinWalletManager::Add(const std::shared_ptr<CWallet>& wallet)
g_wallet_init_interface.InitCoinJoinSettings(*this); g_wallet_init_interface.InitCoinJoinSettings(*this);
} }
void CoinJoinWalletManager::DoMaintenance() void CoinJoinWalletManager::DoMaintenance(CConnman& connman)
{ {
LOCK(cs_wallet_manager_map); LOCK(cs_wallet_manager_map);
for (auto& [_, clientman] : m_wallet_manager_map) { for (auto& [_, clientman] : m_wallet_manager_map) {
clientman->DoMaintenance(m_chainman, m_connman, m_mempool); clientman->DoMaintenance(m_chainman, connman, m_mempool);
} }
} }

View File

@ -76,11 +76,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(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman, CoinJoinWalletManager(ChainstateManager& chainman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
CMasternodeMetaMan& mn_metaman, const CTxMemPool& mempool, const CMasternodeSync& mn_sync, const CTxMemPool& mempool, const CMasternodeSync& mn_sync,
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode) : const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode) :
m_chainman(chainman), m_chainman(chainman),
m_connman(connman),
m_dmnman(dmnman), m_dmnman(dmnman),
m_mn_metaman(mn_metaman), m_mn_metaman(mn_metaman),
m_mempool(mempool), m_mempool(mempool),
@ -97,7 +96,7 @@ public:
} }
void Add(const std::shared_ptr<CWallet>& wallet); void Add(const std::shared_ptr<CWallet>& wallet);
void DoMaintenance(); void DoMaintenance(CConnman& connman);
void Remove(const std::string& name); void Remove(const std::string& name);
void Flush(const std::string& name); void Flush(const std::string& name);
@ -122,7 +121,6 @@ public:
private: private:
ChainstateManager& m_chainman; ChainstateManager& m_chainman;
CConnman& m_connman;
CDeterministicMNManager& m_dmnman; CDeterministicMNManager& m_dmnman;
CMasternodeMetaMan& m_mn_metaman; CMasternodeMetaMan& m_mn_metaman;
const CTxMemPool& m_mempool; const CTxMemPool& m_mempool;

View File

@ -15,7 +15,7 @@ CJContext::CJContext(ChainstateManager& chainman, CConnman& connman, CDeterminis
std::unique_ptr<PeerManager>& peerman, bool relay_txes) : std::unique_ptr<PeerManager>& peerman, bool relay_txes) :
dstxman{std::make_unique<CDSTXManager>()}, dstxman{std::make_unique<CDSTXManager>()},
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
walletman{std::make_unique<CoinJoinWalletManager>(chainman, connman, 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>(connman, peerman, *walletman, dmnman, mn_metaman, ? std::make_unique<CCoinJoinClientQueueManager>(connman, peerman, *walletman, dmnman, mn_metaman,

View File

@ -2297,7 +2297,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
} else if (!ignores_incoming_txs) { } else if (!ignores_incoming_txs) {
node.scheduler->scheduleEvery(std::bind(&CCoinJoinClientQueueManager::DoMaintenance, std::ref(*node.cj_ctx->queueman)), std::chrono::seconds{1}); node.scheduler->scheduleEvery(std::bind(&CCoinJoinClientQueueManager::DoMaintenance, std::ref(*node.cj_ctx->queueman)), std::chrono::seconds{1});
node.scheduler->scheduleEvery(std::bind(&CoinJoinWalletManager::DoMaintenance, std::ref(*node.cj_ctx->walletman)), std::chrono::seconds{1}); node.scheduler->scheduleEvery(std::bind(&CoinJoinWalletManager::DoMaintenance, std::ref(*node.cj_ctx->walletman), std::ref(*node.connman)), std::chrono::seconds{1});
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
} }