Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13711176
D12809.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Subscribers
None
D12809.diff
View Options
diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp
--- a/src/wallet/interfaces.cpp
+++ b/src/wallet/interfaces.cpp
@@ -77,7 +77,10 @@
//! Construct wallet tx status struct.
WalletTxStatus MakeWalletTxStatus(const CWallet &wallet,
- const CWalletTx &wtx) {
+ const CWalletTx &wtx)
+ EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) {
+ AssertLockHeld(wallet.cs_wallet);
+
WalletTxStatus result;
result.block_height = wtx.m_confirm.block_height > 0
? wtx.m_confirm.block_height
@@ -101,6 +104,8 @@
WalletTxOut MakeWalletTxOut(const CWallet &wallet, const CWalletTx &wtx,
int n, int depth)
EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) {
+ AssertLockHeld(wallet.cs_wallet);
+
WalletTxOut result;
result.txout = wtx.tx->vout[n];
result.time = wtx.GetTxTime();
diff --git a/src/wallet/receive.h b/src/wallet/receive.h
--- a/src/wallet/receive.h
+++ b/src/wallet/receive.h
@@ -31,23 +31,24 @@
Amount TxGetChange(const CWallet &wallet, const CTransaction &tx);
Amount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx,
- const isminefilter &filter);
+ const isminefilter &filter)
+ EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
//! filter decides which addresses will count towards the debit
Amount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx,
const isminefilter &filter);
Amount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx);
Amount CachedTxGetImmatureCredit(const CWallet &wallet, const CWalletTx &wtx,
- bool fUseCache = true);
+ bool fUseCache = true)
+ EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
Amount 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.
-Amount CachedTxGetAvailableCredit(
- const CWallet &wallet, const CWalletTx &wtx, bool fUseCache = true,
- const isminefilter &filter = ISMINE_SPENDABLE) NO_THREAD_SAFETY_ANALYSIS;
+ const bool fUseCache = true)
+ EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
+Amount 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;
diff --git a/src/wallet/receive.cpp b/src/wallet/receive.cpp
--- a/src/wallet/receive.cpp
+++ b/src/wallet/receive.cpp
@@ -138,6 +138,8 @@
Amount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx,
const isminefilter &filter) {
+ AssertLockHeld(wallet.cs_wallet);
+
// Must wait until coinbase is safely deep enough in the chain before
// valuing it.
if (wallet.IsTxImmatureCoinBase(wtx)) {
@@ -189,6 +191,8 @@
Amount CachedTxGetImmatureCredit(const CWallet &wallet, const CWalletTx &wtx,
bool fUseCache) {
+ AssertLockHeld(wallet.cs_wallet);
+
if (wallet.IsTxImmatureCoinBase(wtx) && wallet.IsTxInMainChain(wtx)) {
return GetCachableAmount(wallet, wtx, CWalletTx::IMMATURE_CREDIT,
ISMINE_SPENDABLE, !fUseCache);
@@ -200,6 +204,8 @@
Amount CachedTxGetImmatureWatchOnlyCredit(const CWallet &wallet,
const CWalletTx &wtx,
const bool fUseCache) {
+ AssertLockHeld(wallet.cs_wallet);
+
if (wallet.IsTxImmatureCoinBase(wtx) && wallet.IsTxInMainChain(wtx)) {
return GetCachableAmount(wallet, wtx, CWalletTx::IMMATURE_CREDIT,
ISMINE_WATCH_ONLY, !fUseCache);
@@ -210,6 +216,8 @@
Amount 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 =
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -57,7 +57,8 @@
}
static void WalletTxToJSON(const CWallet &wallet, const CWalletTx &wtx,
- UniValue &entry) {
+ UniValue &entry)
+ EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet) {
interfaces::Chain &chain = wallet.chain();
int confirms = wallet.GetTxDepthInMainChain(wtx);
entry.pushKV("confirmations", confirms);
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -452,14 +452,8 @@
const CWalletTx *GetWalletTx(const TxId &txid) const
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
- // 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. Note
- // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
- // in place.
- std::set<TxId>
- GetTxConflicts(const CWalletTx &wtx) const NO_THREAD_SAFETY_ANALYSIS;
+ std::set<TxId> GetTxConflicts(const CWalletTx &wtx) const
+ EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
/**
* Return depth of transaction in blockchain:
@@ -467,15 +461,12 @@
* 0 : in memory pool, waiting to be included in a block
* >=1 : this many blocks deep in the main chain
*/
- // 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. Note
- // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)"
- // in place.
- int
- GetTxDepthInMainChain(const CWalletTx &wtx) const NO_THREAD_SAFETY_ANALYSIS;
- bool IsTxInMainChain(const CWalletTx &wtx) const {
+ int GetTxDepthInMainChain(const CWalletTx &wtx) const
+ EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+ bool IsTxInMainChain(const CWalletTx &wtx) const
+ EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) {
+ AssertLockHeld(cs_wallet);
+
return GetTxDepthInMainChain(wtx) > 0;
}
@@ -484,8 +475,10 @@
* 0 : is not a coinbase transaction, or is a mature coinbase transaction
* >0 : is a coinbase transaction which matures in this many blocks
*/
- int GetTxBlocksToMaturity(const CWalletTx &wtx) const;
- bool IsTxImmatureCoinBase(const CWalletTx &wtx) const;
+ int GetTxBlocksToMaturity(const CWalletTx &wtx) const
+ EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
+ bool IsTxImmatureCoinBase(const CWalletTx &wtx) const
+ EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
//! check whether we are allowed to upgrade (or already support) to the
//! named feature
@@ -694,7 +687,8 @@
* if flag set to true
*/
bool SubmitTxMemoryPoolAndRelay(const CWalletTx &wtx,
- std::string &err_string, bool relay) const;
+ std::string &err_string, bool relay) const
+ EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
bool DummySignTx(CMutableTransaction &txNew, const std::set<CTxOut> &txouts,
bool use_max_sig = false) const {
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -657,6 +657,8 @@
* Outpoint is spent if any non-conflicted transaction, spends it:
*/
bool CWallet::IsSpent(const COutPoint &outpoint) const {
+ AssertLockHeld(cs_wallet);
+
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range =
mapTxSpends.equal_range(outpoint);
@@ -1841,6 +1843,8 @@
}
void CWallet::ReacceptWalletTransactions() {
+ AssertLockHeld(cs_wallet);
+
// If transactions aren't being broadcasted, don't let them into local
// mempool either.
if (!fBroadcastTransactions) {
@@ -1874,6 +1878,8 @@
bool CWallet::SubmitTxMemoryPoolAndRelay(const CWalletTx &wtx,
std::string &err_string,
bool relay) const {
+ AssertLockHeld(cs_wallet);
+
// Can't relay if wallet is not broadcasting
if (!GetBroadcastTransactions()) {
return false;
@@ -1911,6 +1917,8 @@
}
std::set<TxId> CWallet::GetTxConflicts(const CWalletTx &wtx) const {
+ AssertLockHeld(cs_wallet);
+
std::set<TxId> result;
const TxId &txid = wtx.GetId();
result = GetConflicts(txid);
@@ -3107,6 +3115,8 @@
}
int CWallet::GetTxBlocksToMaturity(const CWalletTx &wtx) const {
+ AssertLockHeld(cs_wallet);
+
if (!wtx.IsCoinBase()) {
return 0;
}
@@ -3117,6 +3127,8 @@
}
bool CWallet::IsTxImmatureCoinBase(const CWalletTx &wtx) const {
+ AssertLockHeld(cs_wallet);
+
// note GetBlocksToMaturity is 0 for non-coinbase tx
return GetTxBlocksToMaturity(wtx) > 0;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 26, 10:41 (1 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5573319
Default Alt Text
D12809.diff (9 KB)
Attached To
D12809: Remove NO_THREAD_SAFETY_ANALYSIS from non-test/benchmarking code
Event Timeline
Log In to Comment