Skip to content

Commit 3f77dfd

Browse files
committed
Expose ancestorsize and ancestorfees via getTransactionAncestry
1 parent 42af959 commit 3f77dfd

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

src/interfaces/chain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class Chain
174174
std::string& err_string) = 0;
175175

176176
//! Calculate mempool ancestor and descendant counts for the given transaction.
177-
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) = 0;
177+
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) = 0;
178178

179179
//! Get the node's package limits.
180180
//! Currently only returns the ancestor and descendant count limits, but could be enhanced to

src/node/interfaces.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,11 @@ class ChainImpl : public Chain
574574
// that Chain clients do not need to know about.
575575
return TransactionError::OK == err;
576576
}
577-
void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) override
577+
void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize, CAmount* ancestorfees) override
578578
{
579579
ancestors = descendants = 0;
580580
if (!m_node.mempool) return;
581-
m_node.mempool->GetTransactionAncestry(txid, ancestors, descendants);
581+
m_node.mempool->GetTransactionAncestry(txid, ancestors, descendants, ancestorsize, ancestorfees);
582582
}
583583
void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) override
584584
{

src/txmempool.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,12 +1116,14 @@ uint64_t CTxMemPool::CalculateDescendantMaximum(txiter entry) const {
11161116
return maximum;
11171117
}
11181118

1119-
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const {
1119+
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* const ancestorsize, CAmount* const ancestorfees) const {
11201120
LOCK(cs);
11211121
auto it = mapTx.find(txid);
11221122
ancestors = descendants = 0;
11231123
if (it != mapTx.end()) {
11241124
ancestors = it->GetCountWithAncestors();
1125+
if (ancestorsize) *ancestorsize = it->GetSizeWithAncestors();
1126+
if (ancestorfees) *ancestorfees = it->GetModFeesWithAncestors();
11251127
descendants = CalculateDescendantMaximum(it);
11261128
}
11271129
}

src/txmempool.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,10 @@ class CTxMemPool
706706
/**
707707
* Calculate the ancestor and descendant count for the given transaction.
708708
* The counts include the transaction itself.
709+
* When ancestors is non-zero (ie, the transaction itself is in the mempool),
710+
* ancestorsize and ancestorfees will also be set to the appropriate values.
709711
*/
710-
void GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const;
712+
void GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) const;
711713

712714
/** @returns true if the mempool is fully loaded */
713715
bool IsLoaded() const;

0 commit comments

Comments
 (0)