diff options
author | Karl-Johan Alm <karljohan-alm@garage.co.jp> | 2018-03-08 12:15:42 -0500 |
---|---|---|
committer | Karl-Johan Alm <karljohan-alm@garage.co.jp> | 2018-06-11 19:04:55 +0900 |
commit | 475a385a80198a46a6d99846f99b968f04e9b470 (patch) | |
tree | 90b792ecd5f336c4f7c35051f6d90060348ea004 /src/txmempool.cpp | |
parent | 46847d69d2c1cc908fd779daac7884e365955dbd (diff) |
Add GetTransactionAncestry to CTxMemPool for general purpose chain limit checking
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 52d223656b..4f740b7c0a 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -1066,6 +1066,16 @@ uint64_t CTxMemPool::CalculateDescendantMaximum(txiter entry) const { return top->GetCountWithDescendants(); } +void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) const { + LOCK(cs); + auto it = mapTx.find(txid); + ancestors = descendants = 0; + if (it != mapTx.end()) { + ancestors = it->GetCountWithAncestors(); + descendants = CalculateDescendantMaximum(it); + } +} + bool CTxMemPool::TransactionWithinChainLimit(const uint256& txid, size_t ancestor_limit, size_t descendant_limit) const { LOCK(cs); auto it = mapTx.find(txid); |