aboutsummaryrefslogtreecommitdiff
path: root/src/policy
diff options
context:
space:
mode:
Diffstat (limited to 'src/policy')
-rw-r--r--src/policy/fees.cpp11
-rw-r--r--src/policy/fees.h7
2 files changed, 15 insertions, 3 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index 7da171d2e1..2b70c18b7e 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -473,6 +473,12 @@ void TxConfirmStats::removeTx(unsigned int entryHeight, unsigned int nBestSeenHe
bool CBlockPolicyEstimator::removeTx(uint256 hash, bool inBlock)
{
LOCK(m_cs_fee_estimator);
+ return _removeTx(hash, inBlock);
+}
+
+bool CBlockPolicyEstimator::_removeTx(const uint256& hash, bool inBlock)
+{
+ AssertLockHeld(m_cs_fee_estimator);
std::map<uint256, TxStatsInfo>::iterator pos = mapMemPoolTxs.find(hash);
if (pos != mapMemPoolTxs.end()) {
feeStats->removeTx(pos->second.blockHeight, nBestSeenHeight, pos->second.bucketIndex, inBlock);
@@ -556,7 +562,8 @@ void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, boo
bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry)
{
- if (!removeTx(entry->GetTx().GetHash(), true)) {
+ AssertLockHeld(m_cs_fee_estimator);
+ if (!_removeTx(entry->GetTx().GetHash(), true)) {
// This transaction wasn't being tracked for fee estimation
return false;
}
@@ -965,7 +972,7 @@ void CBlockPolicyEstimator::FlushUnconfirmed() {
// Remove every entry in mapMemPoolTxs
while (!mapMemPoolTxs.empty()) {
auto mi = mapMemPoolTxs.begin();
- removeTx(mi->first, false); // this calls erase() on mapMemPoolTxs
+ _removeTx(mi->first, false); // this calls erase() on mapMemPoolTxs
}
int64_t endclear = GetTimeMicros();
LogPrint(BCLog::ESTIMATEFEE, "Recorded %u unconfirmed txs from mempool in %gs\n", num_entries, (endclear - startclear)*0.000001);
diff --git a/src/policy/fees.h b/src/policy/fees.h
index a1fddc9562..fdbf956930 100644
--- a/src/policy/fees.h
+++ b/src/policy/fees.h
@@ -194,7 +194,8 @@ public:
EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator);
/** Remove a transaction from the mempool tracking stats*/
- bool removeTx(uint256 hash, bool inBlock);
+ bool removeTx(uint256 hash, bool inBlock)
+ EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator);
/** DEPRECATED. Return a feerate estimate */
CFeeRate estimateFee(int confTarget) const
@@ -278,6 +279,10 @@ private:
unsigned int HistoricalBlockSpan() const EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);
/** Calculation of highest target that reasonable estimate can be provided for */
unsigned int MaxUsableEstimate() const EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);
+
+ /** A non-thread-safe helper for the removeTx function */
+ bool _removeTx(const uint256& hash, bool inBlock)
+ EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);
};
class FeeFilterRounder