Skip to content

Commit

Permalink
refactor: move CConnman out of CoinJoinWalletManager ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Dec 4, 2024
1 parent 7fddb32 commit 4ea26dd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/coinjoin/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1917,11 +1917,11 @@ void CoinJoinWalletManager::Add(const std::shared_ptr<CWallet>& 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);
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/coinjoin/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ class CoinJoinWalletManager {
using wallet_name_cjman_map = std::map<const std::string, std::unique_ptr<CCoinJoinClientManager>>;

public:
CoinJoinWalletManager(ChainstateManager& chainman, CConnman& connman, CDeterministicMNManager& dmnman,
CoinJoinWalletManager(ChainstateManager& chainman, CDeterministicMNManager& dmnman,
CMasternodeMetaMan& mn_metaman, const CTxMemPool& mempool, const CMasternodeSync& mn_sync,
const std::unique_ptr<CCoinJoinClientQueueManager>& queueman, bool is_masternode) :
m_chainman(chainman),
m_connman(connman),
m_dmnman(dmnman),
m_mn_metaman(mn_metaman),
m_mempool(mempool),
Expand All @@ -97,7 +96,7 @@ class CoinJoinWalletManager {
}

void Add(const std::shared_ptr<CWallet>& wallet);
void DoMaintenance();
void DoMaintenance(CConnman& connman);

void Remove(const std::string& name);
void Flush(const std::string& name);
Expand All @@ -122,7 +121,6 @@ class CoinJoinWalletManager {

private:
ChainstateManager& m_chainman;
CConnman& m_connman;
CDeterministicMNManager& m_dmnman;
CMasternodeMetaMan& m_mn_metaman;
const CTxMemPool& m_mempool;
Expand Down
4 changes: 2 additions & 2 deletions src/coinjoin/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ CJContext::CJContext(ChainstateManager& chainman, CConnman& connman, CDeterminis
std::unique_ptr<PeerManager>& peerman, bool relay_txes) :
dstxman{std::make_unique<CDSTXManager>()},
#ifdef ENABLE_WALLET
walletman{std::make_unique<CoinJoinWalletManager>(chainman, connman, dmnman, mn_metaman, mempool, mn_sync, queueman,
/* is_masternode = */ mn_activeman != nullptr)},
walletman{std::make_unique<CoinJoinWalletManager>(chainman, dmnman, mn_metaman, mempool, mn_sync, queueman,
/*is_masternode=*/mn_activeman != nullptr)},
queueman{relay_txes
? std::make_unique<CCoinJoinClientQueueManager>(connman, peerman, *walletman, dmnman, mn_metaman,
mn_sync, /* is_masternode = */ mn_activeman != nullptr)
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 4ea26dd

Please sign in to comment.