Use mempool/txgraph to determine if a tx has descendants
Remove a reference to GetCountWithDescendants() in preparation for removing this function and the associated cached state from the mempool.
This commit is contained in:
1 parent
69e1eaa6ed
commit
bdcefb8a8b
3 files changed
+11
-4
No files matched your search
@@ -665,10 +665,7 @@ public:
|
|||||||
bool hasDescendantsInMempool(const Txid& txid) override
|
bool hasDescendantsInMempool(const Txid& txid) override
|
||||||
{
|
{
|
||||||
if (!m_node.mempool) return false;
|
if (!m_node.mempool) return false;
|
||||||
LOCK(m_node.mempool->cs);
|
return m_node.mempool->HasDescendants(txid);
|
||||||
const auto entry{m_node.mempool->GetEntry(txid)};
|
|
||||||
if (entry == nullptr) return false;
|
|
||||||
return entry->GetCountWithDescendants() > 1;
|
|
||||||
}
|
}
|
||||||
bool broadcastTransaction(const CTransactionRef& tx,
|
bool broadcastTransaction(const CTransactionRef& tx,
|
||||||
const CAmount& max_tx_fee,
|
const CAmount& max_tx_fee,
|
||||||
|
|||||||
@@ -229,6 +229,14 @@ util::Result<void> CTxMemPool::CheckPackageLimits(const Package& package,
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CTxMemPool::HasDescendants(const Txid& txid) const
|
||||||
|
{
|
||||||
|
LOCK(cs);
|
||||||
|
auto entry = GetEntry(txid);
|
||||||
|
if (!entry) return false;
|
||||||
|
return m_txgraph->GetDescendants(*entry, TxGraph::Level::MAIN).size() > 1;
|
||||||
|
}
|
||||||
|
|
||||||
util::Result<CTxMemPool::setEntries> CTxMemPool::CalculateMemPoolAncestors(
|
util::Result<CTxMemPool::setEntries> CTxMemPool::CalculateMemPoolAncestors(
|
||||||
const CTxMemPoolEntry &entry,
|
const CTxMemPoolEntry &entry,
|
||||||
const Limits& limits,
|
const Limits& limits,
|
||||||
|
|||||||
@@ -467,6 +467,8 @@ public:
|
|||||||
const Limits& limits,
|
const Limits& limits,
|
||||||
bool fSearchForParents = true) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
bool fSearchForParents = true) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||||
|
|
||||||
|
bool HasDescendants(const Txid& txid) const;
|
||||||
|
|
||||||
/** Collect the entire cluster of connected transactions for each transaction in txids.
|
/** Collect the entire cluster of connected transactions for each transaction in txids.
|
||||||
* All txids must correspond to transaction entries in the mempool, otherwise this returns an
|
* All txids must correspond to transaction entries in the mempool, otherwise this returns an
|
||||||
* empty vector. This call will also exit early and return an empty vector if it collects 500 or
|
* empty vector. This call will also exit early and return an empty vector if it collects 500 or
|
||||||
|
|||||||
Reference in new issue
Block a user