From 939807768acd508932f2efabee660d56324a73df Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 1 Sep 2020 12:12:47 +0300 Subject: refactor: CTxMemPool::UpdateParent() requires CTxMemPool::cs lock No change in behavior, the lock is already held at call sites. --- src/txmempool.cpp | 1 + src/txmempool.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index de1a3ec68f..ef2ec661e8 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -978,6 +978,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); diff --git a/src/txmempool.h b/src/txmempool.h index 4743e1b63a..fbff1afcca 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -568,7 +568,7 @@ private: typedef std::map txlinksMap; txlinksMap mapLinks; - void UpdateParent(txiter entry, txiter parent, bool add); + void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs); void UpdateChild(txiter entry, txiter child, bool add); std::vector GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs); -- cgit v1.2.3 From 66e47e5e506043fbb9b4e487b44bf992985709c9 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 1 Sep 2020 12:18:20 +0300 Subject: refactor: CTxMemPool::UpdateChild() requires CTxMemPool::cs lock No change in behavior, the lock is already held at call sites. --- src/txmempool.cpp | 1 + src/txmempool.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index ef2ec661e8..ea6d7e808c 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -968,6 +968,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); diff --git a/src/txmempool.h b/src/txmempool.h index fbff1afcca..05455b8bdd 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -569,7 +569,7 @@ private: txlinksMap mapLinks; void UpdateParent(txiter entry, txiter parent, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs); - void UpdateChild(txiter entry, txiter child, bool add); + void UpdateChild(txiter entry, txiter child, bool add) EXCLUSIVE_LOCKS_REQUIRED(cs); std::vector GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs); -- cgit v1.2.3 From 7140b31b90cbd84d75eedb3e395d0d55f83b5b95 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 1 Sep 2020 12:22:21 +0300 Subject: refactor: CTxMemPool::ApplyDelta() requires CTxMemPool::cs lock No change in behavior, the lock is already held at call sites. Also `const uint256` refactored to `const uint256&`. --- src/txmempool.cpp | 4 ++-- src/txmempool.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index ea6d7e808c..00b1fb38f8 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -852,9 +852,9 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD LogPrintf("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::const_iterator pos = mapDeltas.find(hash); if (pos == mapDeltas.end()) return; diff --git a/src/txmempool.h b/src/txmempool.h index 05455b8bdd..46bcf85712 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -626,7 +626,7 @@ public: /** Affect CreateNewBlock prioritisation of transactions */ void PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta); - void ApplyDelta(const uint256 hash, CAmount &nFeeDelta) const; + void ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs); void ClearPrioritisation(const uint256 hash); /** Get the transaction in the pool that spends the same prevout */ -- cgit v1.2.3 From fa5fcb032b6ed04c49ee465235288b8059fa805e Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 1 Sep 2020 12:30:21 +0300 Subject: refactor: CTxMemPool::ClearPrioritisation() requires CTxMemPool::cs lock No change in behavior, the lock is already held at call sites. Also `const uint256` refactored to `const uint256&`. --- src/txmempool.cpp | 4 ++-- src/txmempool.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 00b1fb38f8..f60809e196 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -862,9 +862,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); } diff --git a/src/txmempool.h b/src/txmempool.h index 46bcf85712..ddd87d2eb3 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -627,7 +627,7 @@ public: /** Affect CreateNewBlock prioritisation of transactions */ void PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta); void ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs); - void ClearPrioritisation(const uint256 hash); + 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); -- cgit v1.2.3 From 7c4bd0387a01a0c3e2938d530dba3c882e4d8f2b Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 1 Sep 2020 12:33:39 +0300 Subject: refactor: CTxMemPool::GetTotalTxSize() requires CTxMemPool::cs lock No change in behavior, the lock is already held at call sites. --- src/txmempool.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/txmempool.h b/src/txmempool.h index ddd87d2eb3..6e286faf80 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -710,9 +710,9 @@ public: return mapTx.size(); } - uint64_t GetTotalTxSize() const + uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs) { - LOCK(cs); + AssertLockHeld(cs); return totalTxSize; } -- cgit v1.2.3 From 020f0519ec66d9626255b938e1c6c3f7f9aa4017 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 1 Sep 2020 12:36:27 +0300 Subject: refactor: CTxMemPool::IsUnbroadcastTx() requires CTxMemPool::cs lock No change in behavior, the lock is already held at call sites. --- src/txmempool.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/txmempool.h b/src/txmempool.h index 6e286faf80..f773cd4825 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -757,9 +757,10 @@ public: } /** Returns whether a txid is in the unbroadcast set */ - bool IsUnbroadcastTx(const uint256& txid) const { - LOCK(cs); - return (m_unbroadcast_txids.count(txid) != 0); + bool IsUnbroadcastTx(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs) + { + AssertLockHeld(cs); + return m_unbroadcast_txids.count(txid) != 0; } private: -- cgit v1.2.3