-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: dangling point to cj client #7259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
9452854
f61af76
66c8443
721233d
bfc3c02
d9a3c74
646af49
fbf9d09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,60 +20,6 @@ using wallet::CWallet; | |
| namespace coinjoin { | ||
| namespace { | ||
|
|
||
| class CoinJoinClientImpl : public interfaces::CoinJoin::Client | ||
| { | ||
| CCoinJoinClientManager& m_clientman; | ||
|
|
||
| public: | ||
| explicit CoinJoinClientImpl(CCoinJoinClientManager& clientman) | ||
| : m_clientman(clientman) {} | ||
|
|
||
| void resetCachedBlocks() override | ||
| { | ||
| m_clientman.nCachedNumBlocks = std::numeric_limits<int>::max(); | ||
| } | ||
| void resetPool() override | ||
| { | ||
| m_clientman.ResetPool(); | ||
| } | ||
| void disableAutobackups() override | ||
| { | ||
| m_clientman.fCreateAutoBackups = false; | ||
| } | ||
| int getCachedBlocks() override | ||
| { | ||
| return m_clientman.nCachedNumBlocks; | ||
| } | ||
| void getJsonInfo(UniValue& obj) override | ||
| { | ||
| return m_clientman.GetJsonInfo(obj); | ||
| } | ||
| std::string getSessionDenoms() override | ||
| { | ||
| return m_clientman.GetSessionDenoms(); | ||
| } | ||
| std::vector<std::string> getSessionStatuses() override | ||
| { | ||
| return m_clientman.GetStatuses(); | ||
| } | ||
| void setCachedBlocks(int nCachedBlocks) override | ||
| { | ||
| m_clientman.nCachedNumBlocks = nCachedBlocks; | ||
| } | ||
| bool isMixing() override | ||
| { | ||
| return m_clientman.IsMixing(); | ||
| } | ||
| bool startMixing() override | ||
| { | ||
| return m_clientman.StartMixing(); | ||
| } | ||
| void stopMixing() override | ||
| { | ||
| m_clientman.StopMixing(); | ||
| } | ||
| }; | ||
|
|
||
| class CoinJoinLoaderImpl : public interfaces::CoinJoin::Loader | ||
| { | ||
| private: | ||
|
|
@@ -82,37 +28,32 @@ class CoinJoinLoaderImpl : public interfaces::CoinJoin::Loader | |
| return *Assert(m_node.cj_walletman); | ||
| } | ||
|
|
||
| interfaces::WalletLoader& wallet_loader() | ||
| { | ||
| return *Assert(m_node.wallet_loader); | ||
| } | ||
|
|
||
| public: | ||
| explicit CoinJoinLoaderImpl(NodeContext& node) : | ||
| m_node(node) | ||
| { | ||
| // Enablement will be re-evaluated when a wallet is added or removed | ||
| CCoinJoinClientOptions::SetEnabled(false); | ||
| CCoinJoinClientOptions::SetEnabled(gArgs.GetBoolArg("-enablecoinjoin", true)); | ||
| } | ||
|
|
||
| void AddWallet(const std::shared_ptr<CWallet>& wallet) override | ||
| { | ||
| manager().addWallet(wallet); | ||
| g_wallet_init_interface.InitCoinJoinSettings(*this, wallet_loader()); | ||
| if (!CCoinJoinClientOptions::IsEnabled()) return; | ||
| manager().doForClient(wallet->GetName(), [](CCoinJoinClientManager& mgr) { | ||
| g_wallet_init_interface.InitCoinJoinSettings(mgr); | ||
| }); | ||
| } | ||
|
Comment on lines
38
to
45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion:
source: ['claude'] 🤖 Fix this with AI agents |
||
| void RemoveWallet(const std::string& name) override | ||
| { | ||
| manager().removeWallet(name); | ||
| g_wallet_init_interface.InitCoinJoinSettings(*this, wallet_loader()); | ||
| } | ||
| void FlushWallet(const std::string& name) override | ||
| { | ||
| manager().flushWallet(name); | ||
| } | ||
| std::unique_ptr<interfaces::CoinJoin::Client> GetClient(const std::string& name) override | ||
| bool WithClient(const std::string& name, const std::function<void(interfaces::CoinJoin::Client&)>& func) override | ||
| { | ||
| auto clientman = manager().getClient(name); | ||
| return clientman ? std::make_unique<CoinJoinClientImpl>(*clientman) : nullptr; | ||
| return manager().doForClient(name, [&](CCoinJoinClientManager& mgr) { func(mgr); }); | ||
| } | ||
|
|
||
| NodeContext& m_node; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 Nitpick:
CoinJoinLoaderImplconstructor readsgArgsand flips globalSetEnabledCoinJoinLoaderImplnow callsCCoinJoinClientOptions::SetEnabled(gArgs.GetBoolArg("-enablecoinjoin", true))unconditionally at construction. Previous behaviour initialised the flag to false and only flipped it once a wallet was added (and back off on last-wallet removal). Per the commit message this is intentional, but: (1) for non-wallet builds the loader is still constructed viaMakeCoinJoinLoader, so this now flips a global totrueeven when no client will exist (benign but easy to miss); (2) readinggArgsfrom a constructor ties unit tests to global-state ordering (coinjoin_options_testsnow mustForceSetArg("-enablecoinjoin", "0")before building the loader,src/wallet/test/coinjoin_tests.cpp:30). Consider passing the enabled value explicitly into the constructor to decouple fromgArgs.source: ['claude']