diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-05-16 18:24:36 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-05-16 20:51:39 +0200 |
commit | ca446f2c59720c1575aeeab9c9d636d98ce8528c (patch) | |
tree | 43ed4261d3c361fb06615bcc377b3e883c36a0ce /src/wallet | |
parent | 187504b038cc1151e5813ac56b79c603439d352c (diff) |
Add proper thread safety annotation to `CachedTxGetAvailableCredit()`
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/receive.cpp | 2 | ||||
-rw-r--r-- | src/wallet/receive.h | 7 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/wallet/receive.cpp b/src/wallet/receive.cpp index cddf94aab2..b38e09b454 100644 --- a/src/wallet/receive.cpp +++ b/src/wallet/receive.cpp @@ -182,6 +182,8 @@ CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet& wallet, const CWalletT CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache, const isminefilter& filter) { + AssertLockHeld(wallet.cs_wallet); + // Avoid caching ismine for NO or ALL cases (could remove this check and simplify in the future). bool allow_cache = (filter & ISMINE_ALL) && (filter & ISMINE_ALL) != ISMINE_ALL; diff --git a/src/wallet/receive.h b/src/wallet/receive.h index d7705b5262..06724ee473 100644 --- a/src/wallet/receive.h +++ b/src/wallet/receive.h @@ -30,11 +30,8 @@ CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const ismi CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx); CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true); CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet& wallet, const CWalletTx& wtx, const bool fUseCache = true); -// TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct -// annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The -// annotation "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid -// having to resolve the issue of member access into incomplete type CWallet. -CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE) NO_THREAD_SAFETY_ANALYSIS; +CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE) + EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet); struct COutputEntry { CTxDestination destination; |