Skip to content

Commit a874ab5

Browse files
committed
remove internal tracking of mempool conflicts for reporting to wallet
1 parent bf663f8 commit a874ab5

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

src/test/blockencodings_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
8080

8181
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1);
8282

83-
std::vector<CTransactionRef> removed;
84-
pool.removeRecursive(*block.vtx[2], &removed);
85-
BOOST_CHECK_EQUAL(removed.size(), 1);
83+
size_t poolSize = pool.size();
84+
pool.removeRecursive(*block.vtx[2]);
85+
BOOST_CHECK_EQUAL(pool.size(), poolSize - 1);
8686

8787
CBlock block2;
8888
std::vector<CTransactionRef> vtx_missing;

src/test/mempool_tests.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
5555

5656

5757
CTxMemPool testPool(CFeeRate(0));
58-
std::vector<CTransactionRef> removed;
5958

6059
// Nothing in pool, remove should do nothing:
61-
testPool.removeRecursive(txParent, &removed);
62-
BOOST_CHECK_EQUAL(removed.size(), 0);
60+
unsigned int poolSize = testPool.size();
61+
testPool.removeRecursive(txParent);
62+
BOOST_CHECK_EQUAL(testPool.size(), poolSize);
6363

6464
// Just the parent:
6565
testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent));
66-
testPool.removeRecursive(txParent, &removed);
67-
BOOST_CHECK_EQUAL(removed.size(), 1);
68-
removed.clear();
66+
poolSize = testPool.size();
67+
testPool.removeRecursive(txParent);
68+
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 1);
6969

7070
// Parent, children, grandchildren:
7171
testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent));
@@ -75,19 +75,21 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
7575
testPool.addUnchecked(txGrandChild[i].GetHash(), entry.FromTx(txGrandChild[i]));
7676
}
7777
// Remove Child[0], GrandChild[0] should be removed:
78-
testPool.removeRecursive(txChild[0], &removed);
79-
BOOST_CHECK_EQUAL(removed.size(), 2);
80-
removed.clear();
78+
poolSize = testPool.size();
79+
testPool.removeRecursive(txChild[0]);
80+
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 2);
8181
// ... make sure grandchild and child are gone:
82-
testPool.removeRecursive(txGrandChild[0], &removed);
83-
BOOST_CHECK_EQUAL(removed.size(), 0);
84-
testPool.removeRecursive(txChild[0], &removed);
85-
BOOST_CHECK_EQUAL(removed.size(), 0);
82+
poolSize = testPool.size();
83+
testPool.removeRecursive(txGrandChild[0]);
84+
BOOST_CHECK_EQUAL(testPool.size(), poolSize);
85+
poolSize = testPool.size();
86+
testPool.removeRecursive(txChild[0]);
87+
BOOST_CHECK_EQUAL(testPool.size(), poolSize);
8688
// Remove parent, all children/grandchildren should go:
87-
testPool.removeRecursive(txParent, &removed);
88-
BOOST_CHECK_EQUAL(removed.size(), 5);
89+
poolSize = testPool.size();
90+
testPool.removeRecursive(txParent);
91+
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 5);
8992
BOOST_CHECK_EQUAL(testPool.size(), 0);
90-
removed.clear();
9193

9294
// Add children and grandchildren, but NOT the parent (simulate the parent being in a block)
9395
for (int i = 0; i < 3; i++)
@@ -97,10 +99,10 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
9799
}
98100
// Now remove the parent, as might happen if a block-re-org occurs but the parent cannot be
99101
// put into the mempool (maybe because it is non-standard):
100-
testPool.removeRecursive(txParent, &removed);
101-
BOOST_CHECK_EQUAL(removed.size(), 6);
102+
poolSize = testPool.size();
103+
testPool.removeRecursive(txParent);
104+
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 6);
102105
BOOST_CHECK_EQUAL(testPool.size(), 0);
103-
removed.clear();
104106
}
105107

106108
template<typename name>

src/txmempool.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ void CTxMemPool::CalculateDescendants(txiter entryit, setEntries &setDescendants
503503
}
504504
}
505505

506-
void CTxMemPool::removeRecursive(const CTransaction &origTx, std::vector<CTransactionRef>* removed)
506+
void CTxMemPool::removeRecursive(const CTransaction &origTx)
507507
{
508508
// Remove transaction from memory pool
509509
{
@@ -530,11 +530,6 @@ void CTxMemPool::removeRecursive(const CTransaction &origTx, std::vector<CTransa
530530
BOOST_FOREACH(txiter it, txToRemove) {
531531
CalculateDescendants(it, setAllRemoves);
532532
}
533-
if (removed) {
534-
BOOST_FOREACH(txiter it, setAllRemoves) {
535-
removed->emplace_back(it->GetSharedTx());
536-
}
537-
}
538533
RemoveStaged(setAllRemoves, false);
539534
}
540535
}
@@ -576,7 +571,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
576571
RemoveStaged(setAllRemoves, false);
577572
}
578573

579-
void CTxMemPool::removeConflicts(const CTransaction &tx, std::vector<CTransactionRef>* removed)
574+
void CTxMemPool::removeConflicts(const CTransaction &tx)
580575
{
581576
// Remove transactions which depend on inputs of tx, recursively
582577
LOCK(cs);
@@ -586,7 +581,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::vector<CTransactio
586581
const CTransaction &txConflict = *it->second;
587582
if (txConflict != tx)
588583
{
589-
removeRecursive(txConflict, removed);
584+
removeRecursive(txConflict);
590585
ClearPrioritisation(txConflict.GetHash());
591586
}
592587
}

src/txmempool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,9 @@ class CTxMemPool
527527
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, bool fCurrentEstimate = true);
528528
bool addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry, setEntries &setAncestors, bool fCurrentEstimate = true);
529529

530-
void removeRecursive(const CTransaction &tx, std::vector<CTransactionRef>* removed = NULL);
530+
void removeRecursive(const CTransaction &tx);
531531
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
532-
void removeConflicts(const CTransaction &tx, std::vector<CTransactionRef>* removed = NULL);
532+
void removeConflicts(const CTransaction &tx);
533533
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight,
534534
bool fCurrentEstimate = true);
535535
void clear();

0 commit comments

Comments
 (0)