mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Merge bitcoin/bitcoin#22003: txmempool: add thread safety annotations
793b268284
txmempool: add thread safety annotations (Anthony Towns) Pull request description: Add missing thread safety guards to CTxMempool members. ACKs for top commit: MarcoFalke: cr ACK793b268284
hebasto: re-ACK793b268284
, only suggested changes since my [previous](https://github.com/bitcoin/bitcoin/pull/22003#pullrequestreview-664529633) review. Tree-SHA512: c5eb197c63375c80c325a276f322177e84e0181c94a124720b1a364e964ac223fc6fdfd89bd0e152b76959fb6b97bfbf82dd36ec105ed6e2dc045ede717df4ae
This commit is contained in:
commit
1cc38d3e01
2 changed files with 8 additions and 7 deletions
|
@ -21,8 +21,9 @@ std::vector<COutPoint> g_outpoints_coinbase_init_mature;
|
||||||
std::vector<COutPoint> g_outpoints_coinbase_init_immature;
|
std::vector<COutPoint> g_outpoints_coinbase_init_immature;
|
||||||
|
|
||||||
struct MockedTxPool : public CTxMemPool {
|
struct MockedTxPool : public CTxMemPool {
|
||||||
void RollingFeeUpdate()
|
void RollingFeeUpdate() EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
|
LOCK(cs);
|
||||||
lastRollingFeeUpdate = GetTime();
|
lastRollingFeeUpdate = GetTime();
|
||||||
blockSinceLastRollingFeeBump = true;
|
blockSinceLastRollingFeeBump = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,21 +479,21 @@ class CTxMemPool
|
||||||
protected:
|
protected:
|
||||||
const int m_check_ratio; //!< Value n means that 1 times in n we check.
|
const int m_check_ratio; //!< Value n means that 1 times in n we check.
|
||||||
std::atomic<unsigned int> nTransactionsUpdated{0}; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation
|
std::atomic<unsigned int> nTransactionsUpdated{0}; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation
|
||||||
CBlockPolicyEstimator* minerPolicyEstimator;
|
CBlockPolicyEstimator* const minerPolicyEstimator;
|
||||||
|
|
||||||
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.
|
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.
|
||||||
CAmount m_total_fee GUARDED_BY(cs); //!< sum of all mempool tx's fees (NOT modified fee)
|
CAmount m_total_fee GUARDED_BY(cs); //!< sum of all mempool tx's fees (NOT modified fee)
|
||||||
uint64_t cachedInnerUsage GUARDED_BY(cs); //!< sum of dynamic memory usage of all the map elements (NOT the maps themselves)
|
uint64_t cachedInnerUsage GUARDED_BY(cs); //!< sum of dynamic memory usage of all the map elements (NOT the maps themselves)
|
||||||
|
|
||||||
mutable int64_t lastRollingFeeUpdate;
|
mutable int64_t lastRollingFeeUpdate GUARDED_BY(cs);
|
||||||
mutable bool blockSinceLastRollingFeeBump;
|
mutable bool blockSinceLastRollingFeeBump GUARDED_BY(cs);
|
||||||
mutable double rollingMinimumFeeRate; //!< minimum fee to get into the pool, decreases exponentially
|
mutable double rollingMinimumFeeRate GUARDED_BY(cs); //!< minimum fee to get into the pool, decreases exponentially
|
||||||
mutable Epoch m_epoch GUARDED_BY(cs);
|
mutable Epoch m_epoch GUARDED_BY(cs);
|
||||||
|
|
||||||
// In-memory counter for external mempool tracking purposes.
|
// In-memory counter for external mempool tracking purposes.
|
||||||
// This number is incremented once every time a transaction
|
// This number is incremented once every time a transaction
|
||||||
// is added or removed from the mempool for any reason.
|
// is added or removed from the mempool for any reason.
|
||||||
mutable uint64_t m_sequence_number{1};
|
mutable uint64_t m_sequence_number GUARDED_BY(cs){1};
|
||||||
|
|
||||||
void trackPackageRemoved(const CFeeRate& rate) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
void trackPackageRemoved(const CFeeRate& rate) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
indirectmap<COutPoint, const CTransaction*> mapNextTx GUARDED_BY(cs);
|
indirectmap<COutPoint, const CTransaction*> mapNextTx GUARDED_BY(cs);
|
||||||
std::map<uint256, CAmount> mapDeltas;
|
std::map<uint256, CAmount> mapDeltas GUARDED_BY(cs);
|
||||||
|
|
||||||
/** Create a new CTxMemPool.
|
/** Create a new CTxMemPool.
|
||||||
* Sanity checks will be off by default for performance, because otherwise
|
* Sanity checks will be off by default for performance, because otherwise
|
||||||
|
|
Loading…
Add table
Reference in a new issue