Skip to content

Commit fa818e1

Browse files
author
MarcoFalke
committed
txmempool: Remove unused clear() member function
1 parent 6061eb6 commit fa818e1

File tree

3 files changed

+13
-32
lines changed

3 files changed

+13
-32
lines changed

src/test/txvalidationcache_tests.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
7777
LOCK(cs_main);
7878
BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->GetBlockHash() != block.GetHash());
7979
}
80-
m_node.mempool->clear();
80+
BOOST_CHECK_EQUAL(m_node.mempool->size(), 1U);
81+
WITH_LOCK(m_node.mempool->cs, m_node.mempool->removeRecursive(CTransaction{spends[0]}, MemPoolRemovalReason::CONFLICT));
82+
BOOST_CHECK_EQUAL(m_node.mempool->size(), 0U);
8183

8284
// Test 3: ... and should be rejected if spend2 is in the memory pool
8385
BOOST_CHECK(ToMemPool(spends[1]));
@@ -86,7 +88,9 @@ BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, Dersig100Setup)
8688
LOCK(cs_main);
8789
BOOST_CHECK(m_node.chainman->ActiveChain().Tip()->GetBlockHash() != block.GetHash());
8890
}
89-
m_node.mempool->clear();
91+
BOOST_CHECK_EQUAL(m_node.mempool->size(), 1U);
92+
WITH_LOCK(m_node.mempool->cs, m_node.mempool->removeRecursive(CTransaction{spends[1]}, MemPoolRemovalReason::CONFLICT));
93+
BOOST_CHECK_EQUAL(m_node.mempool->size(), 0U);
9094

9195
// Final sanity test: first spend in *m_node.mempool, second in block, that's OK:
9296
std::vector<CMutableTransaction> oneSpend;

src/txmempool.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ CTxMemPool::CTxMemPool(const Options& opts)
389389
m_full_rbf{opts.full_rbf},
390390
m_limits{opts.limits}
391391
{
392-
_clear(); //lock free clear
393392
}
394393

395394
bool CTxMemPool::isSpent(const COutPoint& outpoint) const
@@ -627,26 +626,6 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
627626
blockSinceLastRollingFeeBump = true;
628627
}
629628

630-
void CTxMemPool::_clear()
631-
{
632-
vTxHashes.clear();
633-
mapTx.clear();
634-
mapNextTx.clear();
635-
totalTxSize = 0;
636-
m_total_fee = 0;
637-
cachedInnerUsage = 0;
638-
lastRollingFeeUpdate = GetTime();
639-
blockSinceLastRollingFeeBump = false;
640-
rollingMinimumFeeRate = 0;
641-
++nTransactionsUpdated;
642-
}
643-
644-
void CTxMemPool::clear()
645-
{
646-
LOCK(cs);
647-
_clear();
648-
}
649-
650629
void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendheight) const
651630
{
652631
if (m_check_ratio == 0) return;

src/txmempool.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,14 @@ class CTxMemPool
317317
std::atomic<unsigned int> nTransactionsUpdated{0}; //!< Used by getblocktemplate to trigger CreateNewBlock() invocation
318318
CBlockPolicyEstimator* const minerPolicyEstimator;
319319

320-
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.
321-
CAmount m_total_fee GUARDED_BY(cs); //!< sum of all mempool tx's fees (NOT modified fee)
322-
uint64_t cachedInnerUsage GUARDED_BY(cs); //!< sum of dynamic memory usage of all the map elements (NOT the maps themselves)
320+
uint64_t totalTxSize GUARDED_BY(cs){0}; //!< sum of all mempool tx's virtual sizes. Differs from serialized tx size since witness data is discounted. Defined in BIP 141.
321+
CAmount m_total_fee GUARDED_BY(cs){0}; //!< sum of all mempool tx's fees (NOT modified fee)
322+
uint64_t cachedInnerUsage GUARDED_BY(cs){0}; //!< sum of dynamic memory usage of all the map elements (NOT the maps themselves)
323323

324-
mutable int64_t lastRollingFeeUpdate GUARDED_BY(cs);
325-
mutable bool blockSinceLastRollingFeeBump GUARDED_BY(cs);
326-
mutable double rollingMinimumFeeRate GUARDED_BY(cs); //!< minimum fee to get into the pool, decreases exponentially
327-
mutable Epoch m_epoch GUARDED_BY(cs);
324+
mutable int64_t lastRollingFeeUpdate GUARDED_BY(cs){GetTime()};
325+
mutable bool blockSinceLastRollingFeeBump GUARDED_BY(cs){false};
326+
mutable double rollingMinimumFeeRate GUARDED_BY(cs){0}; //!< minimum fee to get into the pool, decreases exponentially
327+
mutable Epoch m_epoch GUARDED_BY(cs){};
328328

329329
// In-memory counter for external mempool tracking purposes.
330330
// This number is incremented once every time a transaction
@@ -502,8 +502,6 @@ class CTxMemPool
502502
void removeConflicts(const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
503503
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
504504

505-
void clear();
506-
void _clear() EXCLUSIVE_LOCKS_REQUIRED(cs); //lock free
507505
bool CompareDepthAndScore(const uint256& hasha, const uint256& hashb, bool wtxid=false);
508506
void queryHashes(std::vector<uint256>& vtxid) const;
509507
bool isSpent(const COutPoint& outpoint) const;

0 commit comments

Comments
 (0)