Merge bitcoin/bitcoin#19833: wallet: Avoid locking cs_wallet recursively
5fabde6fadwallet: AddWalletDescriptor requires cs_wallet lock (João Barbosa)32d036e8dawallet: GetLabelAddresses requires cs_wallet lock (João Barbosa) Pull request description: This is another small change towards non recursive wallet lock. ACKs for top commit: hebasto: ACK5fabde6fad, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 00506f0159c56854a171e58a451db8dd9b9f735039697b1cf2ca7f54de61fb51cc1e5eff42265233e041b4b1bfd29c2247496dc4456578e1a23c323bdec2901b
This commit is contained in:
2 files changed
+5
-4
No files matched your search
@@ -2191,7 +2191,7 @@ void CWallet::MarkDestinationsDirty(const std::set<CTxDestination>& destinations
|
|||||||
|
|
||||||
std::set<CTxDestination> CWallet::GetLabelAddresses(const std::string& label) const
|
std::set<CTxDestination> CWallet::GetLabelAddresses(const std::string& label) const
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
AssertLockHeld(cs_wallet);
|
||||||
std::set<CTxDestination> result;
|
std::set<CTxDestination> result;
|
||||||
for (const std::pair<const CTxDestination, CAddressBookData>& item : m_address_book)
|
for (const std::pair<const CTxDestination, CAddressBookData>& item : m_address_book)
|
||||||
{
|
{
|
||||||
@@ -3252,12 +3252,13 @@ DescriptorScriptPubKeyMan* CWallet::GetDescriptorScriptPubKeyMan(const WalletDes
|
|||||||
|
|
||||||
ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal)
|
ScriptPubKeyMan* CWallet::AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal)
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(cs_wallet);
|
||||||
|
|
||||||
if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||||
WalletLogPrintf("Cannot add WalletDescriptor to a non-descriptor wallet\n");
|
WalletLogPrintf("Cannot add WalletDescriptor to a non-descriptor wallet\n");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK(cs_wallet);
|
|
||||||
auto spk_man = GetDescriptorScriptPubKeyMan(desc);
|
auto spk_man = GetDescriptorScriptPubKeyMan(desc);
|
||||||
if (spk_man) {
|
if (spk_man) {
|
||||||
WalletLogPrintf("Update existing descriptor: %s\n", desc.descriptor->ToString());
|
WalletLogPrintf("Update existing descriptor: %s\n", desc.descriptor->ToString());
|
||||||
|
|||||||
+2
-2
@@ -630,7 +630,7 @@ public:
|
|||||||
|
|
||||||
int64_t GetOldestKeyPoolTime() const;
|
int64_t GetOldestKeyPoolTime() const;
|
||||||
|
|
||||||
std::set<CTxDestination> GetLabelAddresses(const std::string& label) const;
|
std::set<CTxDestination> GetLabelAddresses(const std::string& label) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks all outputs in each one of the destinations dirty, so their cache is
|
* Marks all outputs in each one of the destinations dirty, so their cache is
|
||||||
@@ -876,7 +876,7 @@ public:
|
|||||||
DescriptorScriptPubKeyMan* GetDescriptorScriptPubKeyMan(const WalletDescriptor& desc) const;
|
DescriptorScriptPubKeyMan* GetDescriptorScriptPubKeyMan(const WalletDescriptor& desc) const;
|
||||||
|
|
||||||
//! Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type
|
//! Add a descriptor to the wallet, return a ScriptPubKeyMan & associated output type
|
||||||
ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal);
|
ScriptPubKeyMan* AddWalletDescriptor(WalletDescriptor& desc, const FlatSigningProvider& signing_provider, const std::string& label, bool internal) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user