Skip to content

Commit dd5f571

Browse files
committed
Merge bitcoin/bitcoin#28391: refactor: Simplify CTxMempool/BlockAssembler fields, remove some external mapTx access
4dd94ca [refactor] remove access to mapTx in validation_block_tests (TheCharlatan) d0cd2e8 [refactor] rewrite BlockAssembler inBlock and failedTx as sets of txids (glozow) 55b0939 scripted-diff: rename vTxHashes to txns_randomized (TheCharlatan) a03aef9 [refactor] rewrite vTxHashes as a vector of CTransactionRef (glozow) 938643c [refactor] remove access to mapTx in validation.cpp (glozow) 333367a [txmempool] make CTxMemPoolEntry::lockPoints mutable (glozow) 1bf4855 [refactor] use CheckPackageLimits for checkChainLimits (glozow) dbc5bdb [refactor] remove access to mapTx.find in mempool_tests.cpp (glozow) f80909e [refactor] remove access to mapTx in blockencodings_tests.cpp (glozow) 8892d6b [refactor] remove access to mapTx from rpc/mempool.cpp (glozow) fad61aa [refactor] get wtxid from entry instead of vTxHashes (glozow) 9cd8caf [refactor] use exists() instead of mapTx.find() (glozow) 1480469 [refactor] remove access to mapTx from policy/rbf.cpp (glozow) 1c6a73a [refactor] Add helper for retrieving mempool entry (TheCharlatan) 453b481 [refactor] Add helper for iterating through mempool entries (stickies-v) Pull request description: Motivation * It seems preferable to use stdlib data structures instead of boost if they can achieve close to the same thing. * Code external to mempool should ideally use its public helper methods instead of accessing `mapTx` or its iterators directly. * Reduce the number of complex boost multi index type interactions * Also see #28335 for further context/motivation. This PR together with #28385 simplifies that one. Overview of things done in this PR: * Make `vTxHashes` a vector of transaction references instead of a pair of transaction hash and iterator. The trade off here is that the data is retrieved on the fly with `GetEntry` instead of being cached in `vTxHashes`. * Introduce `GetEntry` helper method to replace the more involved `GetIter` where applicable * Replace `mapTx` access with `CTxMemPool` helper methods * Simplify `checkChainLimits` call in `node/interfaces.cpp` * Make `CTxMemPoolEntry`s `lockPoints`mutable such that they can be changed with a const iterator directly instead of going through `mapTx` * Make `BlockAssembler`'s `inBlock` and `failedTx` sets of transaction hashes. ACKs for top commit: glozow: reACK 4dd94ca maflcko: re-ACK 4dd94ca 👝 stickies-v: re-ACK 4dd94ca Tree-SHA512: c4d043f2186e4fde337591883fac66cade3058173987b49502bd65cecf69207a3df1077f6626809652ab63230013167b7f39a2b39f1c5166959e5495df57065f
2 parents e11b758 + 4dd94ca commit dd5f571

14 files changed

+113
-94
lines changed

src/blockencodings.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
107107
std::vector<bool> have_txn(txn_available.size());
108108
{
109109
LOCK(pool->cs);
110-
for (size_t i = 0; i < pool->vTxHashes.size(); i++) {
111-
uint64_t shortid = cmpctblock.GetShortID(pool->vTxHashes[i].first);
110+
for (const auto& tx : pool->txns_randomized) {
111+
uint64_t shortid = cmpctblock.GetShortID(tx->GetWitnessHash());
112112
std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid);
113113
if (idit != shorttxids.end()) {
114114
if (!have_txn[idit->second]) {
115-
txn_available[idit->second] = pool->vTxHashes[i].second->GetSharedTx();
115+
txn_available[idit->second] = tx;
116116
have_txn[idit->second] = true;
117117
mempool_count++;
118118
} else {

src/kernel/mempool_entry.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CTxMemPoolEntry
8383
const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
8484
const int64_t sigOpCost; //!< Total sigop cost
8585
CAmount m_modified_fee; //!< Used for determining the priority of the transaction for mining in a block
86-
LockPoints lockPoints; //!< Track the height and time at which tx was final
86+
mutable LockPoints lockPoints; //!< Track the height and time at which tx was final
8787

8888
// Information about descendants of this transaction that are in the
8989
// mempool; if we remove this transaction we must remove all of these
@@ -151,7 +151,7 @@ class CTxMemPoolEntry
151151
}
152152

153153
// Update the LockPoints after a reorg
154-
void UpdateLockPoints(const LockPoints& lp)
154+
void UpdateLockPoints(const LockPoints& lp) const
155155
{
156156
lockPoints = lp;
157157
}
@@ -172,8 +172,10 @@ class CTxMemPoolEntry
172172
Parents& GetMemPoolParents() const { return m_parents; }
173173
Children& GetMemPoolChildren() const { return m_children; }
174174

175-
mutable size_t vTxHashesIdx; //!< Index in mempool's vTxHashes
175+
mutable size_t idx_randomized; //!< Index in mempool's txns_randomized
176176
mutable Epoch::Marker m_epoch_marker; //!< epoch when last touched, useful for graph algorithms
177177
};
178178

179+
using CTxMemPoolEntryRef = CTxMemPoolEntry::CTxMemPoolEntryRef;
180+
179181
#endif // BITCOIN_KERNEL_MEMPOOL_ENTRY_H

src/node/interfaces.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,9 @@ class ChainImpl : public Chain
648648
{
649649
if (!m_node.mempool) return false;
650650
LOCK(m_node.mempool->cs);
651-
auto it = m_node.mempool->GetIter(txid);
652-
return it && (*it)->GetCountWithDescendants() > 1;
651+
const auto entry{m_node.mempool->GetEntry(Txid::FromUint256(txid))};
652+
if (entry == nullptr) return false;
653+
return entry->GetCountWithDescendants() > 1;
653654
}
654655
bool broadcastTransaction(const CTransactionRef& tx,
655656
const CAmount& max_tx_fee,
@@ -702,9 +703,9 @@ class ChainImpl : public Chain
702703
if (!m_node.mempool) return true;
703704
LockPoints lp;
704705
CTxMemPoolEntry entry(tx, 0, 0, 0, 0, false, 0, lp);
705-
const CTxMemPool::Limits& limits{m_node.mempool->m_limits};
706706
LOCK(m_node.mempool->cs);
707-
return m_node.mempool->CalculateMemPoolAncestors(entry, limits).has_value();
707+
std::string err_string;
708+
return m_node.mempool->CheckPackageLimits({tx}, entry.GetTxSize(), err_string);
708709
}
709710
CFeeRate estimateSmartFee(int num_blocks, bool conservative, FeeCalculation* calc) override
710711
{
@@ -806,7 +807,7 @@ class ChainImpl : public Chain
806807
{
807808
if (!m_node.mempool) return;
808809
LOCK2(::cs_main, m_node.mempool->cs);
809-
for (const CTxMemPoolEntry& entry : m_node.mempool->mapTx) {
810+
for (const CTxMemPoolEntry& entry : m_node.mempool->entryAll()) {
810811
notifications.transactionAddedToMempool(entry.GetSharedTx());
811812
}
812813
}

src/node/miner.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet)
188188
{
189189
for (CTxMemPool::setEntries::iterator iit = testSet.begin(); iit != testSet.end(); ) {
190190
// Only test txs not already in the block
191-
if (inBlock.count(*iit)) {
191+
if (inBlock.count((*iit)->GetSharedTx()->GetHash())) {
192192
testSet.erase(iit++);
193193
} else {
194194
iit++;
@@ -229,7 +229,7 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
229229
++nBlockTx;
230230
nBlockSigOpsCost += iter->GetSigOpCost();
231231
nFees += iter->GetFee();
232-
inBlock.insert(iter);
232+
inBlock.insert(iter->GetSharedTx()->GetHash());
233233

234234
bool fPrintPriority = gArgs.GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);
235235
if (fPrintPriority) {
@@ -298,7 +298,7 @@ void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSele
298298
// because some of their txs are already in the block
299299
indexed_modified_transaction_set mapModifiedTx;
300300
// Keep track of entries that failed inclusion, to avoid duplicate work
301-
CTxMemPool::setEntries failedTx;
301+
std::set<Txid> failedTx;
302302

303303
CTxMemPool::indexed_transaction_set::index<ancestor_score>::type::iterator mi = mempool.mapTx.get<ancestor_score>().begin();
304304
CTxMemPool::txiter iter;
@@ -326,7 +326,7 @@ void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSele
326326
if (mi != mempool.mapTx.get<ancestor_score>().end()) {
327327
auto it = mempool.mapTx.project<0>(mi);
328328
assert(it != mempool.mapTx.end());
329-
if (mapModifiedTx.count(it) || inBlock.count(it) || failedTx.count(it)) {
329+
if (mapModifiedTx.count(it) || inBlock.count(it->GetSharedTx()->GetHash()) || failedTx.count(it->GetSharedTx()->GetHash())) {
330330
++mi;
331331
continue;
332332
}
@@ -360,7 +360,7 @@ void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSele
360360

361361
// We skip mapTx entries that are inBlock, and mapModifiedTx shouldn't
362362
// contain anything that is inBlock.
363-
assert(!inBlock.count(iter));
363+
assert(!inBlock.count(iter->GetSharedTx()->GetHash()));
364364

365365
uint64_t packageSize = iter->GetSizeWithAncestors();
366366
CAmount packageFees = iter->GetModFeesWithAncestors();
@@ -382,7 +382,7 @@ void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSele
382382
// we must erase failed entries so that we can consider the
383383
// next best entry on the next loop iteration
384384
mapModifiedTx.get<ancestor_score>().erase(modit);
385-
failedTx.insert(iter);
385+
failedTx.insert(iter->GetSharedTx()->GetHash());
386386
}
387387

388388
++nConsecutiveFailed;
@@ -404,7 +404,7 @@ void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSele
404404
if (!TestPackageTransactions(ancestors)) {
405405
if (fUsingModified) {
406406
mapModifiedTx.get<ancestor_score>().erase(modit);
407-
failedTx.insert(iter);
407+
failedTx.insert(iter->GetSharedTx()->GetHash());
408408
}
409409
continue;
410410
}

src/node/miner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class BlockAssembler
142142
uint64_t nBlockTx;
143143
uint64_t nBlockSigOpsCost;
144144
CAmount nFees;
145-
CTxMemPool::setEntries inBlock;
145+
std::unordered_set<Txid, SaltedTxidHasher> inBlock;
146146

147147
// Chain context for the block
148148
int nHeight;

src/policy/rbf.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <tinyformat.h>
1313
#include <txmempool.h>
1414
#include <uint256.h>
15+
#include <util/check.h>
1516
#include <util/moneystr.h>
1617
#include <util/rbf.h>
1718

@@ -35,7 +36,7 @@ RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool)
3536

3637
// If all the inputs have nSequence >= maxint-1, it still might be
3738
// signaled for RBF if any unconfirmed parents have signaled.
38-
const CTxMemPoolEntry entry{*pool.mapTx.find(tx.GetHash())};
39+
const auto& entry{*Assert(pool.GetEntry(tx.GetHash()))};
3940
auto ancestors{pool.AssumeCalculateMemPoolAncestors(__func__, entry, CTxMemPool::Limits::NoLimits(),
4041
/*fSearchForParents=*/false)};
4142

src/rpc/mempool.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool
290290
info.pushKV("descendantsize", e.GetSizeWithDescendants());
291291
info.pushKV("ancestorcount", e.GetCountWithAncestors());
292292
info.pushKV("ancestorsize", e.GetSizeWithAncestors());
293-
info.pushKV("wtxid", pool.vTxHashes[e.vTxHashesIdx].first.ToString());
293+
info.pushKV("wtxid", e.GetTx().GetWitnessHash().ToString());
294294

295295
UniValue fees(UniValue::VOBJ);
296296
fees.pushKV("base", ValueFromAmount(e.GetFee()));
@@ -316,9 +316,7 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool
316316
info.pushKV("depends", depends);
317317

318318
UniValue spent(UniValue::VARR);
319-
const CTxMemPool::txiter& it = pool.mapTx.find(tx.GetHash());
320-
const CTxMemPoolEntry::Children& children = it->GetMemPoolChildrenConst();
321-
for (const CTxMemPoolEntry& child : children) {
319+
for (const CTxMemPoolEntry& child : e.GetMemPoolChildrenConst()) {
322320
spent.push_back(child.GetTx().GetHash().ToString());
323321
}
324322

@@ -345,14 +343,13 @@ UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose, bool include_mempoo
345343
}
346344
LOCK(pool.cs);
347345
UniValue o(UniValue::VOBJ);
348-
for (const CTxMemPoolEntry& e : pool.mapTx) {
349-
const uint256& hash = e.GetTx().GetHash();
346+
for (const CTxMemPoolEntry& e : pool.entryAll()) {
350347
UniValue info(UniValue::VOBJ);
351348
entryToJSON(pool, info, e);
352349
// Mempool has unique entries so there is no advantage in using
353350
// UniValue::pushKV, which checks if the key already exists in O(N).
354351
// UniValue::pushKVEnd is used instead which currently is O(1).
355-
o.pushKVEnd(hash.ToString(), info);
352+
o.pushKVEnd(e.GetTx().GetHash().ToString(), info);
356353
}
357354
return o;
358355
} else {
@@ -461,12 +458,12 @@ static RPCHelpMan getmempoolancestors()
461458
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
462459
LOCK(mempool.cs);
463460

464-
CTxMemPool::txiter it = mempool.mapTx.find(hash);
465-
if (it == mempool.mapTx.end()) {
461+
const auto entry{mempool.GetEntry(Txid::FromUint256(hash))};
462+
if (entry == nullptr) {
466463
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
467464
}
468465

469-
auto ancestors{mempool.AssumeCalculateMemPoolAncestors(self.m_name, *it, CTxMemPool::Limits::NoLimits(), /*fSearchForParents=*/false)};
466+
auto ancestors{mempool.AssumeCalculateMemPoolAncestors(self.m_name, *entry, CTxMemPool::Limits::NoLimits(), /*fSearchForParents=*/false)};
470467

471468
if (!fVerbose) {
472469
UniValue o(UniValue::VARR);
@@ -522,15 +519,15 @@ static RPCHelpMan getmempooldescendants()
522519
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
523520
LOCK(mempool.cs);
524521

525-
CTxMemPool::txiter it = mempool.mapTx.find(hash);
526-
if (it == mempool.mapTx.end()) {
522+
const auto it{mempool.GetIter(hash)};
523+
if (!it) {
527524
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
528525
}
529526

530527
CTxMemPool::setEntries setDescendants;
531-
mempool.CalculateDescendants(it, setDescendants);
528+
mempool.CalculateDescendants(*it, setDescendants);
532529
// CTxMemPool::CalculateDescendants will include the given tx
533-
setDescendants.erase(it);
530+
setDescendants.erase(*it);
534531

535532
if (!fVerbose) {
536533
UniValue o(UniValue::VARR);
@@ -574,14 +571,13 @@ static RPCHelpMan getmempoolentry()
574571
const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
575572
LOCK(mempool.cs);
576573

577-
CTxMemPool::txiter it = mempool.mapTx.find(hash);
578-
if (it == mempool.mapTx.end()) {
574+
const auto entry{mempool.GetEntry(Txid::FromUint256(hash))};
575+
if (entry == nullptr) {
579576
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
580577
}
581578

582-
const CTxMemPoolEntry &e = *it;
583579
UniValue info(UniValue::VOBJ);
584-
entryToJSON(mempool, info, e);
580+
entryToJSON(mempool, info, *entry);
585581
return info;
586582
},
587583
};

src/test/blockencodings_tests.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static CBlock BuildBlockTestCase() {
5151
}
5252

5353
// Number of shared use_counts we expect for a tx we haven't touched
54-
// (block + mempool + our copy from the GetSharedTx call)
55-
constexpr long SHARED_TX_OFFSET{3};
54+
// (block + mempool entry + mempool txns_randomized + our copy from the GetSharedTx call)
55+
constexpr long SHARED_TX_OFFSET{4};
5656

5757
BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
5858
{
@@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
6262

6363
LOCK2(cs_main, pool.cs);
6464
pool.addUnchecked(entry.FromTx(block.vtx[2]));
65-
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
65+
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);
6666

6767
// Do a simple ShortTxIDs RT
6868
{
@@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
8080
BOOST_CHECK(!partialBlock.IsTxAvailable(1));
8181
BOOST_CHECK( partialBlock.IsTxAvailable(2));
8282

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

8585
size_t poolSize = pool.size();
8686
pool.removeRecursive(*block.vtx[2], MemPoolRemovalReason::REPLACED);
@@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
145145

146146
LOCK2(cs_main, pool.cs);
147147
pool.addUnchecked(entry.FromTx(block.vtx[2]));
148-
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
148+
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);
149149

150150
uint256 txhash;
151151

@@ -170,7 +170,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
170170
BOOST_CHECK( partialBlock.IsTxAvailable(1));
171171
BOOST_CHECK( partialBlock.IsTxAvailable(2));
172172

173-
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); // +1 because of partialBlock
173+
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 1); // +1 because of partialBlock
174174

175175
CBlock block2;
176176
{
@@ -185,7 +185,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
185185
partialBlock.FillBlock(block2, {block.vtx[1]}); // Current implementation doesn't check txn here, but don't require that
186186
partialBlock = tmp;
187187
}
188-
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 2); // +2 because of partialBlock and block2
188+
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 2); // +2 because of partialBlock and block2
189189
bool mutated;
190190
BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated));
191191

@@ -196,15 +196,15 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
196196
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &mutated).ToString());
197197
BOOST_CHECK(!mutated);
198198

199-
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 3); // +2 because of partialBlock and block2 and block3
199+
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 3); // +2 because of partialBlock and block2 and block3
200200

201201
txhash = block.vtx[2]->GetHash();
202202
block.vtx.clear();
203203
block2.vtx.clear();
204204
block3.vtx.clear();
205-
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1 - 1); // + 1 because of partialBlock; -1 because of block.
205+
BOOST_CHECK_EQUAL(pool.get(txhash).use_count(), SHARED_TX_OFFSET + 1 - 1); // + 1 because of partialBlock; -1 because of block.
206206
}
207-
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET - 1); // -1 because of block
207+
BOOST_CHECK_EQUAL(pool.get(txhash).use_count(), SHARED_TX_OFFSET - 1); // -1 because of block
208208
}
209209

210210
BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
@@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
215215

216216
LOCK2(cs_main, pool.cs);
217217
pool.addUnchecked(entry.FromTx(block.vtx[1]));
218-
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0);
218+
BOOST_CHECK_EQUAL(pool.get(block.vtx[1]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);
219219

220220
uint256 txhash;
221221

@@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
240240
BOOST_CHECK( partialBlock.IsTxAvailable(1));
241241
BOOST_CHECK( partialBlock.IsTxAvailable(2));
242242

243-
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1);
243+
BOOST_CHECK_EQUAL(pool.get(block.vtx[1]->GetHash()).use_count(), SHARED_TX_OFFSET + 1);
244244

245245
CBlock block2;
246246
PartiallyDownloadedBlock partialBlockCopy = partialBlock;
@@ -253,9 +253,9 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
253253
txhash = block.vtx[1]->GetHash();
254254
block.vtx.clear();
255255
block2.vtx.clear();
256-
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1 - 1); // + 1 because of partialBlock; -1 because of block.
256+
BOOST_CHECK_EQUAL(pool.get(txhash).use_count(), SHARED_TX_OFFSET + 1 - 1); // + 1 because of partialBlock; -1 because of block.
257257
}
258-
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET - 1); // -1 because of block
258+
BOOST_CHECK_EQUAL(pool.get(txhash).use_count(), SHARED_TX_OFFSET - 1); // -1 because of block
259259
}
260260

261261
BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest)

0 commit comments

Comments
 (0)