Skip to content

Commit 793b268

Browse files
committed
txmempool: add thread safety annotations
1 parent ea8b2e8 commit 793b268

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/test/fuzz/tx_pool.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ std::vector<COutPoint> g_outpoints_coinbase_init_mature;
2121
std::vector<COutPoint> g_outpoints_coinbase_init_immature;
2222

2323
struct MockedTxPool : public CTxMemPool {
24-
void RollingFeeUpdate()
24+
void RollingFeeUpdate() EXCLUSIVE_LOCKS_REQUIRED(!cs)
2525
{
26+
LOCK(cs);
2627
lastRollingFeeUpdate = GetTime();
2728
blockSinceLastRollingFeeBump = true;
2829
}

src/txmempool.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,21 +479,21 @@ class CTxMemPool
479479
protected:
480480
const int m_check_ratio; //!< Value n means that 1 times in n we check.
481481
std::atomic<unsigned int> nTransactionsUpdated{0}; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation
482-
CBlockPolicyEstimator* minerPolicyEstimator;
482+
CBlockPolicyEstimator* const minerPolicyEstimator;
483483

484484
uint64_t totalTxSize GUARDED_BY(cs); //!< sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discounted. Defined in BIP 141.
485485
CAmount m_total_fee GUARDED_BY(cs); //!< sum of all mempool tx's fees (NOT modified fee)
486486
uint64_t cachedInnerUsage GUARDED_BY(cs); //!< sum of dynamic memory usage of all the map elements (NOT the maps themselves)
487487

488-
mutable int64_t lastRollingFeeUpdate;
489-
mutable bool blockSinceLastRollingFeeBump;
490-
mutable double rollingMinimumFeeRate; //!< minimum fee to get into the pool, decreases exponentially
488+
mutable int64_t lastRollingFeeUpdate GUARDED_BY(cs);
489+
mutable bool blockSinceLastRollingFeeBump GUARDED_BY(cs);
490+
mutable double rollingMinimumFeeRate GUARDED_BY(cs); //!< minimum fee to get into the pool, decreases exponentially
491491
mutable Epoch m_epoch GUARDED_BY(cs);
492492

493493
// In-memory counter for external mempool tracking purposes.
494494
// This number is incremented once every time a transaction
495495
// is added or removed from the mempool for any reason.
496-
mutable uint64_t m_sequence_number{1};
496+
mutable uint64_t m_sequence_number GUARDED_BY(cs){1};
497497

498498
void trackPackageRemoved(const CFeeRate& rate) EXCLUSIVE_LOCKS_REQUIRED(cs);
499499

@@ -587,7 +587,7 @@ class CTxMemPool
587587

588588
public:
589589
indirectmap<COutPoint, const CTransaction*> mapNextTx GUARDED_BY(cs);
590-
std::map<uint256, CAmount> mapDeltas;
590+
std::map<uint256, CAmount> mapDeltas GUARDED_BY(cs);
591591

592592
/** Create a new CTxMemPool.
593593
* Sanity checks will be off by default for performance, because otherwise

0 commit comments

Comments
 (0)