From 953ba96ac9191331053859ec57f5e13f45e1e9cd Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:19:51 +0000 Subject: [PATCH] refactor: move `CConnman` out of `CoinJoinWalletManager` ctor --- src/coinjoin/client.cpp | 4 ++-- src/coinjoin/client.h | 8 +++----- src/coinjoin/context.cpp | 4 ++-- src/init.cpp | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index 9ee0fa0d91..7b240c6596 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -1917,11 +1917,11 @@ void CoinJoinWalletManager::Add(const std::shared_ptr& wallet) g_wallet_init_interface.InitCoinJoinSettings(*this); } -void CoinJoinWalletManager::DoMaintenance() +void CoinJoinWalletManager::DoMaintenance(CConnman& connman) { LOCK(cs_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); } } diff --git a/src/coinjoin/client.h b/src/coinjoin/client.h index 0dd1cccb90..69db7d1e73 100644 --- a/src/coinjoin/client.h +++ b/src/coinjoin/client.h @@ -76,11 +76,10 @@ public: using wallet_name_cjman_map = std::map>; public: - CoinJoinWalletManager(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman, - CMasternodeMetaMan& mn_metaman, const CTxMemPool& mempool, const CMasternodeSync& mn_sync, + CoinJoinWalletManager(ChainstateManager& chainman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman, + const CTxMemPool& mempool, const CMasternodeSync& mn_sync, const std::unique_ptr& queueman, bool is_masternode) : m_chainman(chainman), - m_connman(connman), m_dmnman(dmnman), m_mn_metaman(mn_metaman), m_mempool(mempool), @@ -97,7 +96,7 @@ public: } void Add(const std::shared_ptr& wallet); - void DoMaintenance(); + void DoMaintenance(CConnman& connman); void Remove(const std::string& name); void Flush(const std::string& name); @@ -122,7 +121,6 @@ public: private: ChainstateManager& m_chainman; - CConnman& m_connman; CDeterministicMNManager& m_dmnman; CMasternodeMetaMan& m_mn_metaman; const CTxMemPool& m_mempool; diff --git a/src/coinjoin/context.cpp b/src/coinjoin/context.cpp index 8ce72e3b97..cbf8a2b13a 100644 --- a/src/coinjoin/context.cpp +++ b/src/coinjoin/context.cpp @@ -15,8 +15,8 @@ CJContext::CJContext(ChainstateManager& chainman, CConnman& connman, CDeterminis std::unique_ptr& peerman, bool relay_txes) : dstxman{std::make_unique()}, #ifdef ENABLE_WALLET - walletman{std::make_unique(chainman, connman, dmnman, mn_metaman, mempool, mn_sync, queueman, - /* is_masternode = */ mn_activeman != nullptr)}, + walletman{std::make_unique(chainman, dmnman, mn_metaman, mempool, mn_sync, queueman, + /*is_masternode=*/mn_activeman != nullptr)}, queueman{relay_txes ? std::make_unique(connman, peerman, *walletman, dmnman, mn_metaman, mn_sync, /* is_masternode = */ mn_activeman != nullptr) diff --git a/src/init.cpp b/src/init.cpp index 9adbf1aec7..7f167c8715 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2297,7 +2297,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) #ifdef ENABLE_WALLET } 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(&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 }