Skip to content

Commit 1fb0a4a

Browse files
committed
Remove use of CalculateMemPoolAncestors in wallet code
This commit does not change behavior.
1 parent cd32160 commit 1fb0a4a

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

src/interfaces/chain.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ class ChainImpl : public Chain
200200
{
201201
::mempool.GetTransactionAncestry(txid, ancestors, descendants);
202202
}
203+
bool checkChainLimits(CTransactionRef tx) override
204+
{
205+
LockPoints lp;
206+
CTxMemPoolEntry entry(tx, 0, 0, 0, false, 0, lp);
207+
CTxMemPool::setEntries ancestors;
208+
auto limit_ancestor_count = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
209+
auto limit_ancestor_size = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * 1000;
210+
auto limit_descendant_count = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
211+
auto limit_descendant_size = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000;
212+
std::string unused_error_string;
213+
LOCK(::mempool.cs);
214+
return ::mempool.CalculateMemPoolAncestors(entry, ancestors, limit_ancestor_count, limit_ancestor_size,
215+
limit_descendant_count, limit_descendant_size, unused_error_string);
216+
}
203217
};
204218

205219
} // namespace

src/interfaces/chain.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ class Chain
142142

143143
//! Calculate mempool ancestor and descendant counts for the given transaction.
144144
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) = 0;
145+
146+
//! Check chain limits.
147+
virtual bool checkChainLimits(CTransactionRef tx) = 0;
145148
};
146149

147150
//! Interface to let node manage chain clients (wallets, or maybe tools for

src/wallet/wallet.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3127,16 +3127,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
31273127

31283128
if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
31293129
// Lastly, ensure this tx will pass the mempool's chain limits
3130-
LockPoints lp;
3131-
CTxMemPoolEntry entry(tx, 0, 0, 0, false, 0, lp);
3132-
CTxMemPool::setEntries setAncestors;
3133-
size_t nLimitAncestors = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
3134-
size_t nLimitAncestorSize = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000;
3135-
size_t nLimitDescendants = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
3136-
size_t nLimitDescendantSize = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)*1000;
3137-
std::string errString;
3138-
LOCK(::mempool.cs);
3139-
if (!::mempool.CalculateMemPoolAncestors(entry, setAncestors, nLimitAncestors, nLimitAncestorSize, nLimitDescendants, nLimitDescendantSize, errString)) {
3130+
if (!chain().checkChainLimits(tx)) {
31403131
strFailReason = _("Transaction has too long of a mempool chain");
31413132
return false;
31423133
}

0 commit comments

Comments
 (0)