From 9fbe0a4ac26c2fddaa3201cdfd8b69bf1f5ffa01 Mon Sep 17 00:00:00 2001 From: Suhas Daftuar Date: Thu, 28 Sep 2023 15:07:05 -0400 Subject: [PATCH] rpc: Calculate ancestor data from scratch for mempool rpc calls --- src/rpc/mempool.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp index 147af369d34..fa70758a61f 100644 --- a/src/rpc/mempool.cpp +++ b/src/rpc/mempool.cpp @@ -290,20 +290,22 @@ static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPool { AssertLockHeld(pool.cs); + auto [ancestor_count, ancestor_size, ancestor_fees] = pool.CalculateAncestorData(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("ancestorcount", e.GetCountWithAncestors()); - info.pushKV("ancestorsize", e.GetSizeWithAncestors()); + info.pushKV("ancestorcount", ancestor_count); + info.pushKV("ancestorsize", ancestor_size); info.pushKV("wtxid", e.GetTx().GetWitnessHash().ToString()); UniValue fees(UniValue::VOBJ); fees.pushKV("base", ValueFromAmount(e.GetFee())); fees.pushKV("modified", ValueFromAmount(e.GetModifiedFee())); - fees.pushKV("ancestor", ValueFromAmount(e.GetModFeesWithAncestors())); + fees.pushKV("ancestor", ValueFromAmount(ancestor_fees)); fees.pushKV("descendant", ValueFromAmount(e.GetModFeesWithDescendants())); info.pushKV("fees", std::move(fees));