Skip to content

Commit 9a789d4

Browse files
policy: Add Clang thread safety annotations for variables guarded by cs_feeEstimator
1 parent ed12fd8 commit 9a789d4

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/policy/fees.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,12 @@ class CBlockPolicyEstimator
228228
unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const;
229229

230230
private:
231-
unsigned int nBestSeenHeight;
232-
unsigned int firstRecordedHeight;
233-
unsigned int historicalFirst;
234-
unsigned int historicalBest;
231+
mutable CCriticalSection cs_feeEstimator;
232+
233+
unsigned int nBestSeenHeight GUARDED_BY(cs_feeEstimator);
234+
unsigned int firstRecordedHeight GUARDED_BY(cs_feeEstimator);
235+
unsigned int historicalFirst GUARDED_BY(cs_feeEstimator);
236+
unsigned int historicalBest GUARDED_BY(cs_feeEstimator);
235237

236238
struct TxStatsInfo
237239
{
@@ -241,34 +243,32 @@ class CBlockPolicyEstimator
241243
};
242244

243245
// map of txids to information about that transaction
244-
std::map<uint256, TxStatsInfo> mapMemPoolTxs;
246+
std::map<uint256, TxStatsInfo> mapMemPoolTxs GUARDED_BY(cs_feeEstimator);
245247

246248
/** Classes to track historical data on transaction confirmations */
247249
std::unique_ptr<TxConfirmStats> feeStats;
248250
std::unique_ptr<TxConfirmStats> shortStats;
249251
std::unique_ptr<TxConfirmStats> longStats;
250252

251-
unsigned int trackedTxs;
252-
unsigned int untrackedTxs;
253+
unsigned int trackedTxs GUARDED_BY(cs_feeEstimator);
254+
unsigned int untrackedTxs GUARDED_BY(cs_feeEstimator);
253255

254-
std::vector<double> buckets; // The upper-bound of the range for the bucket (inclusive)
255-
std::map<double, unsigned int> bucketMap; // Map of bucket upper-bound to index into all vectors by bucket
256-
257-
mutable CCriticalSection cs_feeEstimator;
256+
std::vector<double> buckets GUARDED_BY(cs_feeEstimator); // The upper-bound of the range for the bucket (inclusive)
257+
std::map<double, unsigned int> bucketMap GUARDED_BY(cs_feeEstimator); // Map of bucket upper-bound to index into all vectors by bucket
258258

259259
/** Process a transaction confirmed in a block*/
260-
bool processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry);
260+
bool processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry) EXCLUSIVE_LOCKS_REQUIRED(cs_feeEstimator);
261261

262262
/** Helper for estimateSmartFee */
263-
double estimateCombinedFee(unsigned int confTarget, double successThreshold, bool checkShorterHorizon, EstimationResult *result) const;
263+
double estimateCombinedFee(unsigned int confTarget, double successThreshold, bool checkShorterHorizon, EstimationResult *result) const EXCLUSIVE_LOCKS_REQUIRED(cs_feeEstimator);
264264
/** Helper for estimateSmartFee */
265-
double estimateConservativeFee(unsigned int doubleTarget, EstimationResult *result) const;
265+
double estimateConservativeFee(unsigned int doubleTarget, EstimationResult *result) const EXCLUSIVE_LOCKS_REQUIRED(cs_feeEstimator);
266266
/** Number of blocks of data recorded while fee estimates have been running */
267-
unsigned int BlockSpan() const;
267+
unsigned int BlockSpan() const EXCLUSIVE_LOCKS_REQUIRED(cs_feeEstimator);
268268
/** Number of blocks of recorded fee estimate data represented in saved data file */
269-
unsigned int HistoricalBlockSpan() const;
269+
unsigned int HistoricalBlockSpan() const EXCLUSIVE_LOCKS_REQUIRED(cs_feeEstimator);
270270
/** Calculation of highest target that reasonable estimate can be provided for */
271-
unsigned int MaxUsableEstimate() const;
271+
unsigned int MaxUsableEstimate() const EXCLUSIVE_LOCKS_REQUIRED(cs_feeEstimator);
272272
};
273273

274274
class FeeFilterRounder

0 commit comments

Comments
 (0)