diff --git a/src/init.cpp b/src/init.cpp index b48802637..564b2b332 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -205,7 +205,7 @@ void Shutdown() if (fFeeEstimatesInitialized) { - ::feeEstimator.FlushUnconfirmed(::mempool); + ::feeEstimator.FlushUnconfirmed(); fs::path est_path = GetDataDir() / FEE_ESTIMATES_FILENAME; CAutoFile est_fileout(fsbridge::fopen(est_path, "wb"), SER_DISK, CLIENT_VERSION); if (!est_fileout.IsNull()) diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index 9142f3706..79b450e3e 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -981,16 +981,17 @@ bool CBlockPolicyEstimator::Read(CAutoFile& filein) return true; } -void CBlockPolicyEstimator::FlushUnconfirmed(CTxMemPool& pool) { +void CBlockPolicyEstimator::FlushUnconfirmed() { int64_t startclear = GetTimeMicros(); - std::vector txids; - pool.queryHashes(txids); LOCK(cs_feeEstimator); - for (auto& txid : txids) { - removeTx(txid, false); + size_t num_entries = mapMemPoolTxs.size(); + // Remove every entry in mapMemPoolTxs + while (!mapMemPoolTxs.empty()) { + auto mi = mapMemPoolTxs.begin(); + 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",txids.size(), (endclear - startclear)*0.000001); + LogPrint(BCLog::ESTIMATEFEE, "Recorded %u unconfirmed txs from mempool in %gs\n", num_entries, (endclear - startclear)*0.000001); } FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee) diff --git a/src/policy/fees.h b/src/policy/fees.h index 96a842b7a..5f69e989c 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -223,7 +223,7 @@ public: bool Read(CAutoFile& filein); /** Empty mempool transactions on shutdown to record failure to confirm for txs still in mempool */ - void FlushUnconfirmed(CTxMemPool& pool); + void FlushUnconfirmed(); /** Calculation of highest target that estimates are tracked for */ unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const;