diff --git a/src/test/blockencodings_tests.cpp b/src/test/blockencodings_tests.cpp --- a/src/test/blockencodings_tests.cpp +++ b/src/test/blockencodings_tests.cpp @@ -108,7 +108,7 @@ SHARED_TX_OFFSET + 1); size_t poolSize = pool.size(); - pool.removeRecursive(*block.vtx[2]); + pool.removeRecursive(*block.vtx[2], MemPoolRemovalReason::REPLACED); BOOST_CHECK_EQUAL(pool.size(), poolSize - 1); CBlock block2; diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -182,6 +182,8 @@ } } +static constexpr auto REMOVAL_REASON_DUMMY = MemPoolRemovalReason::REPLACED; + BOOST_AUTO_TEST_CASE(MempoolRemoveTest) { // Test CTxMemPool::remove functionality @@ -219,13 +221,13 @@ // Nothing in pool, remove should do nothing: unsigned int poolSize = testPool.size(); - testPool.removeRecursive(CTransaction(txParent)); + testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY); BOOST_CHECK_EQUAL(testPool.size(), poolSize); // Just the parent: testPool.addUnchecked(entry.FromTx(txParent)); poolSize = testPool.size(); - testPool.removeRecursive(CTransaction(txParent)); + testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY); BOOST_CHECK_EQUAL(testPool.size(), poolSize - 1); // Parent, children, grandchildren: @@ -236,18 +238,19 @@ } // Remove Child[0], GrandChild[0] should be removed: poolSize = testPool.size(); - testPool.removeRecursive(CTransaction(txChild[0])); + testPool.removeRecursive(CTransaction(txChild[0]), REMOVAL_REASON_DUMMY); BOOST_CHECK_EQUAL(testPool.size(), poolSize - 2); // ... make sure grandchild and child are gone: poolSize = testPool.size(); - testPool.removeRecursive(CTransaction(txGrandChild[0])); + testPool.removeRecursive(CTransaction(txGrandChild[0]), + REMOVAL_REASON_DUMMY); BOOST_CHECK_EQUAL(testPool.size(), poolSize); poolSize = testPool.size(); - testPool.removeRecursive(CTransaction(txChild[0])); + testPool.removeRecursive(CTransaction(txChild[0]), REMOVAL_REASON_DUMMY); BOOST_CHECK_EQUAL(testPool.size(), poolSize); // Remove parent, all children/grandchildren should go: poolSize = testPool.size(); - testPool.removeRecursive(CTransaction(txParent)); + testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY); BOOST_CHECK_EQUAL(testPool.size(), poolSize - 5); BOOST_CHECK_EQUAL(testPool.size(), 0UL); @@ -261,7 +264,7 @@ // Now remove the parent, as might happen if a block-re-org occurs but the // parent cannot be put into the mempool (maybe because it is non-standard): poolSize = testPool.size(); - testPool.removeRecursive(CTransaction(txParent)); + testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY); BOOST_CHECK_EQUAL(testPool.size(), poolSize - 6); BOOST_CHECK_EQUAL(testPool.size(), 0UL); } @@ -503,11 +506,14 @@ BOOST_CHECK_EQUAL(pool.size(), 10UL); // Now try removing tx10 and verify the sort order returns to normal - pool.removeRecursive(pool.mapTx.find(tx10.GetId())->GetTx()); + pool.removeRecursive(pool.mapTx.find(tx10.GetId())->GetTx(), + REMOVAL_REASON_DUMMY); CheckSort(pool, snapshotOrder, "MempoolIndexingTest7"); - pool.removeRecursive(pool.mapTx.find(tx9.GetId())->GetTx()); - pool.removeRecursive(pool.mapTx.find(tx8.GetId())->GetTx()); + pool.removeRecursive(pool.mapTx.find(tx9.GetId())->GetTx(), + REMOVAL_REASON_DUMMY); + pool.removeRecursive(pool.mapTx.find(tx8.GetId())->GetTx(), + REMOVAL_REASON_DUMMY); } BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest) { diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -185,7 +185,8 @@ // Test that packages above the min relay fee do get included, even if one // of the transactions is below the min relay fee. Remove the low fee // transaction and replace with a higher fee transaction - m_node.mempool->removeRecursive(CTransaction(tx)); + m_node.mempool->removeRecursive(CTransaction(tx), + MemPoolRemovalReason::REPLACED); // Now we should be just over the min relay fee. tx.vout[0].nValue -= 2 * SATOSHI; lowFeeTxId = tx.GetId(); diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -369,8 +369,6 @@ * notification signal. */ enum class MemPoolRemovalReason { - //! Manually removed or unknown reason - UNKNOWN = 0, //! Expired from mempool EXPIRY, //! Removed in size limiting @@ -627,9 +625,7 @@ void addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main); - void removeRecursive( - const CTransaction &tx, - MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN); + void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason); void removeForReorg(const Config &config, const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags) EXCLUSIVE_LOCKS_REQUIRED(cs_main); @@ -679,10 +675,8 @@ * updateDescendants to true when removing a tx that was in a block, so that * any in-mempool descendants have their ancestor state updated. */ - void - RemoveStaged(setEntries &stage, bool updateDescendants, - MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) - EXCLUSIVE_LOCKS_REQUIRED(cs); + void RemoveStaged(setEntries &stage, bool updateDescendants, + MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs); /** * When adding transactions from a disconnected block back to the mempool, @@ -838,9 +832,7 @@ * transaction that is removed, so we can't remove intermediate transactions * in a chain before we've updated all the state for the removal. */ - void - removeUnchecked(txiter entry, - MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) + void removeUnchecked(txiter entry, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs); };