mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-26 15:36:19 +01:00
Merge bitcoin/bitcoin#25148: refactor: Remove NO_THREAD_SAFETY_ANALYSIS from non-test/benchmarking code
a55db4ea1cAdd more proper thread safety annotations (Hennadii Stepanov)8cfe93e3fcAdd proper thread safety annotation to `CWallet::GetTxConflicts()` (Hennadii Stepanov)ca446f2c59Add proper thread safety annotation to `CachedTxGetAvailableCredit()` (Hennadii Stepanov) Pull request description: In non-test/benchmarking code, there are three cases of the `NO_THREAD_SAFETY_ANALYSIS` annotation which are accompanied with `TODO` comments. This PR adds proper thread safety annotations instead of `NO_THREAD_SAFETY_ANALYSIS`. ACKs for top commit: laanwj: Code review ACKa55db4ea1cTree-SHA512: 806d72eebc1edf088bfa435c8cd11465be0de6789798dd92abd008425516768acb864a73d834a49d412bb10f7fccfb47473f998cb72739dab6caeef6bcfaf191
This commit is contained in:
@@ -1841,6 +1841,8 @@ void CWallet::ReacceptWalletTransactions()
|
||||
|
||||
bool CWallet::SubmitTxMemoryPoolAndRelay(CWalletTx& wtx, std::string& err_string, bool relay) const
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
|
||||
// Can't relay if wallet is not broadcasting
|
||||
if (!GetBroadcastTransactions()) return false;
|
||||
// Don't relay abandoned transactions
|
||||
@@ -1869,12 +1871,11 @@ bool CWallet::SubmitTxMemoryPoolAndRelay(CWalletTx& wtx, std::string& err_string
|
||||
|
||||
std::set<uint256> CWallet::GetTxConflicts(const CWalletTx& wtx) const
|
||||
{
|
||||
std::set<uint256> result;
|
||||
{
|
||||
uint256 myHash = wtx.GetHash();
|
||||
result = GetConflicts(myHash);
|
||||
result.erase(myHash);
|
||||
}
|
||||
AssertLockHeld(cs_wallet);
|
||||
|
||||
const uint256 myHash{wtx.GetHash()};
|
||||
std::set<uint256> result{GetConflicts(myHash)};
|
||||
result.erase(myHash);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3128,8 +3129,11 @@ int CWallet::GetTxDepthInMainChain(const CWalletTx& wtx) const
|
||||
|
||||
int CWallet::GetTxBlocksToMaturity(const CWalletTx& wtx) const
|
||||
{
|
||||
if (!wtx.IsCoinBase())
|
||||
AssertLockHeld(cs_wallet);
|
||||
|
||||
if (!wtx.IsCoinBase()) {
|
||||
return 0;
|
||||
}
|
||||
int chain_depth = GetTxDepthInMainChain(wtx);
|
||||
assert(chain_depth >= 0); // coinbase tx should not be conflicted
|
||||
return std::max(0, (COINBASE_MATURITY+1) - chain_depth);
|
||||
@@ -3137,6 +3141,8 @@ int CWallet::GetTxBlocksToMaturity(const CWalletTx& wtx) const
|
||||
|
||||
bool CWallet::IsTxImmatureCoinBase(const CWalletTx& wtx) const
|
||||
{
|
||||
AssertLockHeld(cs_wallet);
|
||||
|
||||
// note GetBlocksToMaturity is 0 for non-coinbase tx
|
||||
return GetTxBlocksToMaturity(wtx) > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user