Skip to content

Commit faef4fc

Browse files
author
MarcoFalke
committed
Remove mempool global from interfaces
1 parent fa83168 commit faef4fc

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/interfaces/chain.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,9 @@ class ChainImpl : public Chain
282282
}
283283
bool hasDescendantsInMempool(const uint256& txid) override
284284
{
285-
LOCK(::mempool.cs);
286-
auto it = ::mempool.GetIter(txid);
285+
if (!m_node.mempool) return false;
286+
LOCK(m_node.mempool->cs);
287+
auto it = m_node.mempool->GetIter(txid);
287288
return it && (*it)->GetCountWithDescendants() > 1;
288289
}
289290
bool broadcastTransaction(const CTransactionRef& tx,
@@ -299,7 +300,9 @@ class ChainImpl : public Chain
299300
}
300301
void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) override
301302
{
302-
::mempool.GetTransactionAncestry(txid, ancestors, descendants);
303+
ancestors = descendants = 0;
304+
if (!m_node.mempool) return;
305+
m_node.mempool->GetTransactionAncestry(txid, ancestors, descendants);
303306
}
304307
void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) override
305308
{
@@ -308,6 +311,7 @@ class ChainImpl : public Chain
308311
}
309312
bool checkChainLimits(const CTransactionRef& tx) override
310313
{
314+
if (!m_node.mempool) return true;
311315
LockPoints lp;
312316
CTxMemPoolEntry entry(tx, 0, 0, 0, false, 0, lp);
313317
CTxMemPool::setEntries ancestors;
@@ -316,8 +320,9 @@ class ChainImpl : public Chain
316320
auto limit_descendant_count = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
317321
auto limit_descendant_size = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000;
318322
std::string unused_error_string;
319-
LOCK(::mempool.cs);
320-
return ::mempool.CalculateMemPoolAncestors(entry, ancestors, limit_ancestor_count, limit_ancestor_size,
323+
LOCK(m_node.mempool->cs);
324+
return m_node.mempool->CalculateMemPoolAncestors(
325+
entry, ancestors, limit_ancestor_count, limit_ancestor_size,
321326
limit_descendant_count, limit_descendant_size, unused_error_string);
322327
}
323328
CFeeRate estimateSmartFee(int num_blocks, bool conservative, FeeCalculation* calc) override
@@ -330,7 +335,8 @@ class ChainImpl : public Chain
330335
}
331336
CFeeRate mempoolMinFee() override
332337
{
333-
return ::mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
338+
if (!m_node.mempool) return {};
339+
return m_node.mempool->GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
334340
}
335341
CFeeRate relayMinFee() override { return ::minRelayTxFee; }
336342
CFeeRate relayIncrementalFee() override { return ::incrementalRelayFee; }
@@ -396,8 +402,9 @@ class ChainImpl : public Chain
396402
}
397403
void requestMempoolTransactions(Notifications& notifications) override
398404
{
399-
LOCK2(::cs_main, ::mempool.cs);
400-
for (const CTxMemPoolEntry& entry : ::mempool.mapTx) {
405+
if (!m_node.mempool) return;
406+
LOCK2(::cs_main, m_node.mempool->cs);
407+
for (const CTxMemPoolEntry& entry : m_node.mempool->mapTx) {
401408
notifications.transactionAddedToMempool(entry.GetSharedTx());
402409
}
403410
}

0 commit comments

Comments
 (0)