Skip to content

Commit ca446f2

Browse files
committed
Add proper thread safety annotation to CachedTxGetAvailableCredit()
1 parent 187504b commit ca446f2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/wallet/receive.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet& wallet, const CWalletT
182182

183183
CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache, const isminefilter& filter)
184184
{
185+
AssertLockHeld(wallet.cs_wallet);
186+
185187
// Avoid caching ismine for NO or ALL cases (could remove this check and simplify in the future).
186188
bool allow_cache = (filter & ISMINE_ALL) && (filter & ISMINE_ALL) != ISMINE_ALL;
187189

src/wallet/receive.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,8 @@ CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const ismi
3030
CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx);
3131
CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true);
3232
CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet& wallet, const CWalletTx& wtx, const bool fUseCache = true);
33-
// TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
34-
// annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The
35-
// annotation "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid
36-
// having to resolve the issue of member access into incomplete type CWallet.
37-
CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE) NO_THREAD_SAFETY_ANALYSIS;
33+
CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE)
34+
EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
3835
struct COutputEntry
3936
{
4037
CTxDestination destination;

0 commit comments

Comments
 (0)