diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -575,8 +575,10 @@ typedef std::map txlinksMap; txlinksMap mapLinks; - 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 GetSortedDepthAndScore() const EXCLUSIVE_LOCKS_REQUIRED(cs); @@ -648,8 +650,9 @@ /** Affect CreateNewBlock prioritisation of transactions */ void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta); - void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const; - void ClearPrioritisation(const TxId &txid); + void ApplyDelta(const TxId &txid, Amount &nFeeDelta) const + EXCLUSIVE_LOCKS_REQUIRED(cs); + void ClearPrioritisation(const TxId &txid) EXCLUSIVE_LOCKS_REQUIRED(cs); /** Get the transaction in the pool that spends the same prevout */ const CTransaction *GetConflictTx(const COutPoint &prevout) const @@ -766,8 +769,8 @@ return mapTx.size(); } - uint64_t GetTotalTxSize() const { - LOCK(cs); + uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs) { + AssertLockHeld(cs); return totalTxSize; } @@ -803,8 +806,8 @@ } /** Returns whether a txid is in the unbroadcast set */ - bool IsUnbroadcastTx(const TxId &txid) const { - LOCK(cs); + bool IsUnbroadcastTx(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs) { + AssertLockHeld(cs); return (m_unbroadcast_txids.count(txid) != 0); } diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -987,7 +987,7 @@ } void CTxMemPool::ApplyDelta(const TxId &txid, Amount &nFeeDelta) const { - LOCK(cs); + AssertLockHeld(cs); std::map::const_iterator pos = mapDeltas.find(txid); if (pos == mapDeltas.end()) { return; @@ -997,7 +997,7 @@ } void CTxMemPool::ClearPrioritisation(const TxId &txid) { - LOCK(cs); + AssertLockHeld(cs); mapDeltas.erase(txid); } @@ -1132,6 +1132,7 @@ } 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); @@ -1141,6 +1142,7 @@ } 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);