mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-20 17:02:14 +02:00
Expose ancestorsize and ancestorfees via getTransactionAncestry
This commit is contained in:
parent
42af9596ce
commit
3f77dfdaf0
@ -174,7 +174,7 @@ public:
|
|||||||
std::string& err_string) = 0;
|
std::string& err_string) = 0;
|
||||||
|
|
||||||
//! Calculate mempool ancestor and descendant counts for the given transaction.
|
//! Calculate mempool ancestor and descendant counts for the given transaction.
|
||||||
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) = 0;
|
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) = 0;
|
||||||
|
|
||||||
//! Get the node's package limits.
|
//! Get the node's package limits.
|
||||||
//! Currently only returns the ancestor and descendant count limits, but could be enhanced to
|
//! Currently only returns the ancestor and descendant count limits, but could be enhanced to
|
||||||
|
@ -574,11 +574,11 @@ public:
|
|||||||
// that Chain clients do not need to know about.
|
// that Chain clients do not need to know about.
|
||||||
return TransactionError::OK == err;
|
return TransactionError::OK == err;
|
||||||
}
|
}
|
||||||
void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) override
|
void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize, CAmount* ancestorfees) override
|
||||||
{
|
{
|
||||||
ancestors = descendants = 0;
|
ancestors = descendants = 0;
|
||||||
if (!m_node.mempool) return;
|
if (!m_node.mempool) return;
|
||||||
m_node.mempool->GetTransactionAncestry(txid, ancestors, descendants);
|
m_node.mempool->GetTransactionAncestry(txid, ancestors, descendants, ancestorsize, ancestorfees);
|
||||||
}
|
}
|
||||||
void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) override
|
void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) override
|
||||||
{
|
{
|
||||||
|
@ -1116,12 +1116,14 @@ uint64_t CTxMemPool::CalculateDescendantMaximum(txiter entry) const {
|
|||||||
return maximum;
|
return maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const {
|
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* const ancestorsize, CAmount* const ancestorfees) const {
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
auto it = mapTx.find(txid);
|
auto it = mapTx.find(txid);
|
||||||
ancestors = descendants = 0;
|
ancestors = descendants = 0;
|
||||||
if (it != mapTx.end()) {
|
if (it != mapTx.end()) {
|
||||||
ancestors = it->GetCountWithAncestors();
|
ancestors = it->GetCountWithAncestors();
|
||||||
|
if (ancestorsize) *ancestorsize = it->GetSizeWithAncestors();
|
||||||
|
if (ancestorfees) *ancestorfees = it->GetModFeesWithAncestors();
|
||||||
descendants = CalculateDescendantMaximum(it);
|
descendants = CalculateDescendantMaximum(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -706,8 +706,10 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Calculate the ancestor and descendant count for the given transaction.
|
* Calculate the ancestor and descendant count for the given transaction.
|
||||||
* The counts include the transaction itself.
|
* The counts include the transaction itself.
|
||||||
|
* When ancestors is non-zero (ie, the transaction itself is in the mempool),
|
||||||
|
* ancestorsize and ancestorfees will also be set to the appropriate values.
|
||||||
*/
|
*/
|
||||||
void GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const;
|
void GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) const;
|
||||||
|
|
||||||
/** @returns true if the mempool is fully loaded */
|
/** @returns true if the mempool is fully loaded */
|
||||||
bool IsLoaded() const;
|
bool IsLoaded() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user