66#include < config/bitcoin-config.h>
77#endif
88
9- #include < coinjoin/context .h>
9+ #include < coinjoin/walletman .h>
1010
1111#include < net.h>
1212#include < scheduler.h>
2121#include < memory>
2222
2323#ifdef ENABLE_WALLET
24- class CJContextImpl final : public CJContext
24+ class CJWalletManagerImpl final : public CJWalletManager
2525{
2626public:
27- CJContextImpl (ChainstateManager& chainman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
28- CTxMemPool& mempool, const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman,
29- bool relay_txes);
30- virtual ~CJContextImpl () = default ;
27+ CJWalletManagerImpl (ChainstateManager& chainman, CDeterministicMNManager& dmnman, CMasternodeMetaMan& mn_metaman,
28+ CTxMemPool& mempool, const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman,
29+ bool relay_txes);
30+ virtual ~CJWalletManagerImpl () = default ;
3131
3232public:
3333 void Schedule (CConnman& connman, CScheduler& scheduler) override ;
@@ -55,16 +55,17 @@ class CJContextImpl final : public CJContext
5555 const std::unique_ptr<CCoinJoinClientQueueManager> queueman;
5656};
5757
58- CJContextImpl::CJContextImpl (ChainstateManager& chainman, CDeterministicMNManager& dmnman,
59- CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool, const CMasternodeSync& mn_sync,
60- const llmq::CInstantSendManager& isman, bool relay_txes) :
58+ CJWalletManagerImpl::CJWalletManagerImpl (ChainstateManager& chainman, CDeterministicMNManager& dmnman,
59+ CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool,
60+ const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman,
61+ bool relay_txes) :
6162 m_relay_txes{relay_txes},
6263 walletman{chainman, dmnman, mn_metaman, mempool, mn_sync, isman, queueman},
6364 queueman{m_relay_txes ? std::make_unique<CCoinJoinClientQueueManager>(walletman, dmnman, mn_metaman, mn_sync) : nullptr }
6465{
6566}
6667
67- void CJContextImpl ::Schedule (CConnman& connman, CScheduler& scheduler)
68+ void CJWalletManagerImpl ::Schedule (CConnman& connman, CScheduler& scheduler)
6869{
6970 if (!m_relay_txes) return ;
7071 scheduler.scheduleEvery (std::bind (&CCoinJoinClientQueueManager::DoMaintenance, std::ref (*queueman)),
@@ -73,7 +74,7 @@ void CJContextImpl::Schedule(CConnman& connman, CScheduler& scheduler)
7374 std::chrono::seconds{1 });
7475}
7576
76- void CJContextImpl ::UpdatedBlockTip (const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload )
77+ void CJWalletManagerImpl ::UpdatedBlockTip (const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload )
7778{
7879 if (fInitialDownload || pindexNew == pindexFork) // In IBD or blocks were disconnected without any new ones
7980 return ;
@@ -82,21 +83,22 @@ void CJContextImpl::UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIn
8283 [&pindexNew](std::unique_ptr<CCoinJoinClientManager>& clientman) { clientman->UpdatedBlockTip (pindexNew); });
8384}
8485
85- bool CJContextImpl ::hasQueue (const uint256& hash) const
86+ bool CJWalletManagerImpl ::hasQueue (const uint256& hash) const
8687{
8788 if (queueman) {
8889 return queueman->HasQueue (hash);
8990 }
9091 return false ;
9192}
9293
93- CCoinJoinClientManager* CJContextImpl ::getClient (const std::string& name)
94+ CCoinJoinClientManager* CJWalletManagerImpl ::getClient (const std::string& name)
9495{
9596 return walletman.Get (name);
9697}
9798
98- MessageProcessingResult CJContextImpl::processMessage (CNode& pfrom, CChainState& chainstate, CConnman& connman,
99- CTxMemPool& mempool, std::string_view msg_type, CDataStream& vRecv)
99+ MessageProcessingResult CJWalletManagerImpl::processMessage (CNode& pfrom, CChainState& chainstate, CConnman& connman,
100+ CTxMemPool& mempool, std::string_view msg_type,
101+ CDataStream& vRecv)
100102{
101103 walletman.ForEachCJClientMan ([&](std::unique_ptr<CCoinJoinClientManager>& clientman) {
102104 clientman->ProcessMessage (pfrom, chainstate, connman, mempool, msg_type, vRecv);
@@ -107,53 +109,53 @@ MessageProcessingResult CJContextImpl::processMessage(CNode& pfrom, CChainState&
107109 return {};
108110}
109111
110- std::optional<CCoinJoinQueue> CJContextImpl ::getQueueFromHash (const uint256& hash) const
112+ std::optional<CCoinJoinQueue> CJWalletManagerImpl ::getQueueFromHash (const uint256& hash) const
111113{
112114 if (queueman) {
113115 return queueman->GetQueueFromHash (hash);
114116 }
115117 return std::nullopt ;
116118}
117119
118- std::optional<int > CJContextImpl ::getQueueSize () const
120+ std::optional<int > CJWalletManagerImpl ::getQueueSize () const
119121{
120122 if (queueman) {
121123 return queueman->GetQueueSize ();
122124 }
123125 return std::nullopt ;
124126}
125127
126- std::vector<CDeterministicMNCPtr> CJContextImpl ::getMixingMasternodes ()
128+ std::vector<CDeterministicMNCPtr> CJWalletManagerImpl ::getMixingMasternodes ()
127129{
128130 std::vector<CDeterministicMNCPtr> ret{};
129131 walletman.ForEachCJClientMan (
130132 [&](const std::unique_ptr<CCoinJoinClientManager>& clientman) { clientman->GetMixingMasternodesInfo (ret); });
131133 return ret;
132134}
133135
134- void CJContextImpl ::addWallet (const std::shared_ptr<wallet::CWallet>& wallet)
136+ void CJWalletManagerImpl ::addWallet (const std::shared_ptr<wallet::CWallet>& wallet)
135137{
136138 walletman.Add (wallet);
137139}
138140
139- void CJContextImpl ::flushWallet (const std::string& name)
141+ void CJWalletManagerImpl ::flushWallet (const std::string& name)
140142{
141143 walletman.Flush (name);
142144}
143145
144- void CJContextImpl ::removeWallet (const std::string& name)
146+ void CJWalletManagerImpl ::removeWallet (const std::string& name)
145147{
146148 walletman.Remove (name);
147149}
148150#endif // ENABLE_WALLET
149151
150- std::unique_ptr<CJContext> CJContext ::make (ChainstateManager& chainman, CDeterministicMNManager& dmnman,
151- CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool,
152- const CMasternodeSync& mn_sync, const llmq::CInstantSendManager& isman ,
153- bool relay_txes)
152+ std::unique_ptr<CJWalletManager> CJWalletManager ::make (ChainstateManager& chainman, CDeterministicMNManager& dmnman,
153+ CMasternodeMetaMan& mn_metaman, CTxMemPool& mempool,
154+ const CMasternodeSync& mn_sync ,
155+ const llmq::CInstantSendManager& isman, bool relay_txes)
154156{
155157#ifdef ENABLE_WALLET
156- return std::make_unique<CJContextImpl >(chainman, dmnman, mn_metaman, mempool, mn_sync, isman, relay_txes);
158+ return std::make_unique<CJWalletManagerImpl >(chainman, dmnman, mn_metaman, mempool, mn_sync, isman, relay_txes);
157159#else
158160 // Cannot be constructed if wallet support isn't built
159161 return nullptr ;
0 commit comments