Skip to content

Commit 0000ff0

Browse files
author
MarcoFalke
committed
txmempool: Remove unused default value MemPoolRemovalReason::UNKNOWN
1 parent 51a6e2c commit 0000ff0

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

src/test/blockencodings_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
8585
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1);
8686

8787
size_t poolSize = pool.size();
88-
pool.removeRecursive(*block.vtx[2]);
88+
pool.removeRecursive(*block.vtx[2], MemPoolRemovalReason::REPLACED);
8989
BOOST_CHECK_EQUAL(pool.size(), poolSize - 1);
9090

9191
CBlock block2;

src/test/mempool_tests.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
BOOST_FIXTURE_TEST_SUITE(mempool_tests, TestingSetup)
1616

17+
static constexpr auto REMOVAL_REASON_DUMMY = MemPoolRemovalReason::REPLACED;
18+
1719
BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
1820
{
1921
// Test CTxMemPool::remove functionality
@@ -59,13 +61,13 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
5961

6062
// Nothing in pool, remove should do nothing:
6163
unsigned int poolSize = testPool.size();
62-
testPool.removeRecursive(CTransaction(txParent));
64+
testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY);
6365
BOOST_CHECK_EQUAL(testPool.size(), poolSize);
6466

6567
// Just the parent:
6668
testPool.addUnchecked(entry.FromTx(txParent));
6769
poolSize = testPool.size();
68-
testPool.removeRecursive(CTransaction(txParent));
70+
testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY);
6971
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 1);
7072

7173
// Parent, children, grandchildren:
@@ -77,18 +79,18 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
7779
}
7880
// Remove Child[0], GrandChild[0] should be removed:
7981
poolSize = testPool.size();
80-
testPool.removeRecursive(CTransaction(txChild[0]));
82+
testPool.removeRecursive(CTransaction(txChild[0]), REMOVAL_REASON_DUMMY);
8183
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 2);
8284
// ... make sure grandchild and child are gone:
8385
poolSize = testPool.size();
84-
testPool.removeRecursive(CTransaction(txGrandChild[0]));
86+
testPool.removeRecursive(CTransaction(txGrandChild[0]), REMOVAL_REASON_DUMMY);
8587
BOOST_CHECK_EQUAL(testPool.size(), poolSize);
8688
poolSize = testPool.size();
87-
testPool.removeRecursive(CTransaction(txChild[0]));
89+
testPool.removeRecursive(CTransaction(txChild[0]), REMOVAL_REASON_DUMMY);
8890
BOOST_CHECK_EQUAL(testPool.size(), poolSize);
8991
// Remove parent, all children/grandchildren should go:
9092
poolSize = testPool.size();
91-
testPool.removeRecursive(CTransaction(txParent));
93+
testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY);
9294
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 5);
9395
BOOST_CHECK_EQUAL(testPool.size(), 0U);
9496

@@ -101,7 +103,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
101103
// Now remove the parent, as might happen if a block-re-org occurs but the parent cannot be
102104
// put into the mempool (maybe because it is non-standard):
103105
poolSize = testPool.size();
104-
testPool.removeRecursive(CTransaction(txParent));
106+
testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY);
105107
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 6);
106108
BOOST_CHECK_EQUAL(testPool.size(), 0U);
107109
}
@@ -283,11 +285,11 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
283285
BOOST_CHECK_EQUAL(pool.size(), 10U);
284286

285287
// Now try removing tx10 and verify the sort order returns to normal
286-
pool.removeRecursive(pool.mapTx.find(tx10.GetHash())->GetTx());
288+
pool.removeRecursive(pool.mapTx.find(tx10.GetHash())->GetTx(), REMOVAL_REASON_DUMMY);
287289
CheckSort<descendant_score>(pool, snapshotOrder);
288290

289-
pool.removeRecursive(pool.mapTx.find(tx9.GetHash())->GetTx());
290-
pool.removeRecursive(pool.mapTx.find(tx8.GetHash())->GetTx());
291+
pool.removeRecursive(pool.mapTx.find(tx9.GetHash())->GetTx(), REMOVAL_REASON_DUMMY);
292+
pool.removeRecursive(pool.mapTx.find(tx8.GetHash())->GetTx(), REMOVAL_REASON_DUMMY);
291293
}
292294

293295
BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)

src/test/miner_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static void TestPackageSelection(const CChainParams& chainparams, const CScript&
158158
// Test that packages above the min relay fee do get included, even if one
159159
// of the transactions is below the min relay fee
160160
// Remove the low fee transaction and replace with a higher fee transaction
161-
mempool.removeRecursive(CTransaction(tx));
161+
mempool.removeRecursive(CTransaction(tx), MemPoolRemovalReason::REPLACED);
162162
tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee
163163
hashLowFeeTx = tx.GetHash();
164164
mempool.addUnchecked(entry.Fee(feeToUse+2).FromTx(tx));

src/txmempool.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ struct TxMempoolInfo
345345
* this is passed to the notification signal.
346346
*/
347347
enum class MemPoolRemovalReason {
348-
UNKNOWN = 0, //!< Manually removed or unknown reason
349348
EXPIRY, //!< Expired from mempool
350349
SIZELIMIT, //!< Removed in size limiting
351350
REORG, //!< Removed for reorganization
@@ -574,7 +573,7 @@ class CTxMemPool
574573
void addUnchecked(const CTxMemPoolEntry& entry, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
575574
void addUnchecked(const CTxMemPoolEntry& entry, setEntries& setAncestors, bool validFeeEstimate = true) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
576575

577-
void removeRecursive(const CTransaction& tx, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs);
576+
void removeRecursive(const CTransaction& tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
578577
void removeForReorg(const CCoinsViewCache* pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main);
579578
void removeConflicts(const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
580579
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);
@@ -613,7 +612,7 @@ class CTxMemPool
613612
* Set updateDescendants to true when removing a tx that was in a block, so
614613
* that any in-mempool descendants have their ancestor state updated.
615614
*/
616-
void RemoveStaged(setEntries &stage, bool updateDescendants, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs);
615+
void RemoveStaged(setEntries& stage, bool updateDescendants, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
617616

618617
/** When adding transactions from a disconnected block back to the mempool,
619618
* new mempool entries may have children in the mempool (which is generally
@@ -735,7 +734,7 @@ class CTxMemPool
735734
* transactions in a chain before we've updated all the state for the
736735
* removal.
737736
*/
738-
void removeUnchecked(txiter entry, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs);
737+
void removeUnchecked(txiter entry, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);
739738
};
740739

741740
/**

0 commit comments

Comments
 (0)