mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #19854: Avoid locking CTxMemPool::cs recursively in simple cases
020f0519ec66d9626255b938e1c6c3f7f9aa4017 refactor: CTxMemPool::IsUnbroadcastTx() requires CTxMemPool::cs lock (Hennadii Stepanov) 7c4bd0387a01a0c3e2938d530dba3c882e4d8f2b refactor: CTxMemPool::GetTotalTxSize() requires CTxMemPool::cs lock (Hennadii Stepanov) fa5fcb032b6ed04c49ee465235288b8059fa805e refactor: CTxMemPool::ClearPrioritisation() requires CTxMemPool::cs lock (Hennadii Stepanov) 7140b31b90cbd84d75eedb3e395d0d55f83b5b95 refactor: CTxMemPool::ApplyDelta() requires CTxMemPool::cs lock (Hennadii Stepanov) 66e47e5e506043fbb9b4e487b44bf992985709c9 refactor: CTxMemPool::UpdateChild() requires CTxMemPool::cs lock (Hennadii Stepanov) 939807768acd508932f2efabee660d56324a73df refactor: CTxMemPool::UpdateParent() requires CTxMemPool::cs lock (Hennadii Stepanov) Pull request description: This is another step to transit `CTxMemPool::cs` from `RecursiveMutex` to `Mutex`. Split out from #19306. Only trivial thread safety annotations and lock assertions added. No new locks. No behavior change. Refactoring `const uint256` to `const uint256&` was [requested](https://github.com/bitcoin/bitcoin/pull/19647#discussion_r468471022) by **promag**. Please note that now, since #19668 has been merged, it is safe to apply `AssertLockHeld()` macros as they do not swallow compile time Thread Safety Analysis warnings. ACKs for top commit: promag: Core review ACK 020f0519ec66d9626255b938e1c6c3f7f9aa4017. jnewbery: Code review ACK 020f0519ec66d9626255b938e1c6c3f7f9aa4017 vasild: ACK 020f0519e Tree-SHA512: a31e389142d5a19b25fef0aaf1072a337278564528b5cc9209df88ae548a31440e1b8dd9bae0169fd7aa59ea06e22fe5e0413955386512b83ef1f3e7d941e890
This commit is contained in:
parent
c618e5cdf8
commit
7dcdc95613
@ -1362,9 +1362,9 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
|
||||
LogPrint(BCLog::MEMPOOL, "PrioritiseTransaction: %s feerate += %s\n", hash.ToString(), FormatMoney(nFeeDelta));
|
||||
}
|
||||
|
||||
void CTxMemPool::ApplyDelta(const uint256 hash, CAmount &nFeeDelta) const
|
||||
void CTxMemPool::ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const
|
||||
{
|
||||
LOCK(cs);
|
||||
AssertLockHeld(cs);
|
||||
std::map<uint256, CAmount>::const_iterator pos = mapDeltas.find(hash);
|
||||
if (pos == mapDeltas.end())
|
||||
return;
|
||||
@ -1372,9 +1372,9 @@ void CTxMemPool::ApplyDelta(const uint256 hash, CAmount &nFeeDelta) const
|
||||
nFeeDelta += delta;
|
||||
}
|
||||
|
||||
void CTxMemPool::ClearPrioritisation(const uint256 hash)
|
||||
void CTxMemPool::ClearPrioritisation(const uint256& hash)
|
||||
{
|
||||
LOCK(cs);
|
||||
AssertLockHeld(cs);
|
||||
mapDeltas.erase(hash);
|
||||
}
|
||||
|
||||
@ -1483,6 +1483,7 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, bool validFeeEstimat
|
||||
|
||||
void CTxMemPool::UpdateChild(txiter entry, txiter child, bool add)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
setEntries s;
|
||||
if (add && mapLinks[entry].children.insert(child).second) {
|
||||
cachedInnerUsage += memusage::IncrementalDynamicUsage(s);
|
||||
@ -1493,6 +1494,7 @@ void CTxMemPool::UpdateChild(txiter entry, txiter child, bool add)
|
||||
|
||||
void CTxMemPool::UpdateParent(txiter entry, txiter parent, bool add)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
setEntries s;
|
||||
if (add && mapLinks[entry].parents.insert(parent).second) {
|
||||
cachedInnerUsage += memusage::IncrementalDynamicUsage(s);
|
||||
|
@ -568,8 +568,8 @@ private:
|
||||
std::map<uint256, uint256> mapProTxBlsPubKeyHashes;
|
||||
std::map<COutPoint, uint256> mapProTxCollaterals;
|
||||
|
||||
void UpdateParent(txiter entry, txiter parent, bool add);
|
||||
void UpdateChild(txiter entry, txiter child, bool add);
|
||||
void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
std::vector<indexed_transaction_set::const_iterator> GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
@ -638,8 +638,8 @@ public:
|
||||
|
||||
/** Affect CreateNewBlock prioritisation of transactions */
|
||||
void PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta);
|
||||
void ApplyDelta(const uint256 hash, CAmount &nFeeDelta) const;
|
||||
void ClearPrioritisation(const uint256 hash);
|
||||
void ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
void ClearPrioritisation(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** Get the transaction in the pool that spends the same prevout */
|
||||
const CTransaction* GetConflictTx(const COutPoint& prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
@ -722,9 +722,9 @@ public:
|
||||
return mapTx.size();
|
||||
}
|
||||
|
||||
uint64_t GetTotalTxSize() const
|
||||
uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
AssertLockHeld(cs);
|
||||
return totalTxSize;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user