diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp index fa70758a61f..b5373697e7a 100644 --- a/src/rpc/mempool.cpp +++ b/src/rpc/mempool.cpp @@ -291,13 +291,14 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool AssertLockHeld(pool.cs); auto [ancestor_count, ancestor_size, ancestor_fees] = pool.CalculateAncestorData(e); + auto [descendant_count, descendant_size, descendant_fees] = pool.CalculateDescendantData(e); info.pushKV("vsize", (int)e.GetTxSize()); info.pushKV("weight", (int)e.GetTxWeight()); info.pushKV("time", count_seconds(e.GetTime())); info.pushKV("height", (int)e.GetHeight()); - info.pushKV("descendantcount", e.GetCountWithDescendants()); - info.pushKV("descendantsize", e.GetSizeWithDescendants()); + info.pushKV("descendantcount", descendant_count); + info.pushKV("descendantsize", descendant_size); info.pushKV("ancestorcount", ancestor_count); info.pushKV("ancestorsize", ancestor_size); info.pushKV("wtxid", e.GetTx().GetWitnessHash().ToString()); @@ -306,7 +307,7 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool fees.pushKV("base", ValueFromAmount(e.GetFee())); fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee())); fees.pushKV("ancestor", ValueFromAmount(ancestor_fees)); - fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants())); + fees.pushKV("descendant", ValueFromAmount(descendant_fees)); info.pushKV("fees", std::move(fees)); const CTransaction& tx = e.GetTx(); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index f7bdbf94e3c..ce9218f9111 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1217,6 +1217,21 @@ std::tuple CTxMemPool::CalculateAncestorData(const CTxM return {ancestor_count, ancestor_size, ancestor_fees}; } +std::tuple CTxMemPool::CalculateDescendantData(const CTxMemPoolEntry& entry) const +{ + auto descendants = m_txgraph->GetDescendants(entry, TxGraph::Level::MAIN); + size_t descendant_count = descendants.size(); + size_t descendant_size = 0; + CAmount descendant_fees = 0; + + for (auto tx: descendants) { + const CTxMemPoolEntry &desc = static_cast(*tx); + descendant_size += desc.GetTxSize(); + descendant_fees += desc.GetModifiedFee(); + } + return {descendant_count, descendant_size, descendant_fees}; +} + void CTxMemPool::GetTransactionAncestry(const Txid& txid, size_t& ancestors, size_t& descendants, size_t* const ancestorsize, CAmount* const ancestorfees) const { LOCK(cs); auto it = mapTx.find(txid); diff --git a/src/txmempool.h b/src/txmempool.h index b65333cc3b3..49ee510a4f0 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -287,6 +287,7 @@ public: uint64_t CalculateDescendantMaximum(txiter entry) const EXCLUSIVE_LOCKS_REQUIRED(cs); std::tuple CalculateAncestorData(const CTxMemPoolEntry& entry) const EXCLUSIVE_LOCKS_REQUIRED(cs); + std::tuple CalculateDescendantData(const CTxMemPoolEntry& entry) const EXCLUSIVE_LOCKS_REQUIRED(cs); private: typedef std::map cacheMap;