Remove use of CalculateMemPoolAncestors in wallet code
This commit does not change behavior.
This commit is contained in:
parent
cd32160af0
commit
1fb0a4a04e
3 changed files with 18 additions and 10 deletions
|
@ -200,6 +200,20 @@ public:
|
||||||
{
|
{
|
||||||
::mempool.GetTransactionAncestry(txid, ancestors, descendants);
|
::mempool.GetTransactionAncestry(txid, ancestors, descendants);
|
||||||
}
|
}
|
||||||
|
bool checkChainLimits(CTransactionRef tx) override
|
||||||
|
{
|
||||||
|
LockPoints lp;
|
||||||
|
CTxMemPoolEntry entry(tx, 0, 0, 0, false, 0, lp);
|
||||||
|
CTxMemPool::setEntries ancestors;
|
||||||
|
auto limit_ancestor_count = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
|
||||||
|
auto limit_ancestor_size = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT) * 1000;
|
||||||
|
auto limit_descendant_count = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
|
||||||
|
auto limit_descendant_size = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000;
|
||||||
|
std::string unused_error_string;
|
||||||
|
LOCK(::mempool.cs);
|
||||||
|
return ::mempool.CalculateMemPoolAncestors(entry, ancestors, limit_ancestor_count, limit_ancestor_size,
|
||||||
|
limit_descendant_count, limit_descendant_size, unused_error_string);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -142,6 +142,9 @@ public:
|
||||||
|
|
||||||
//! 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) = 0;
|
||||||
|
|
||||||
|
//! Check chain limits.
|
||||||
|
virtual bool checkChainLimits(CTransactionRef tx) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Interface to let node manage chain clients (wallets, or maybe tools for
|
//! Interface to let node manage chain clients (wallets, or maybe tools for
|
||||||
|
|
|
@ -3127,16 +3127,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
|
||||||
|
|
||||||
if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
|
if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
|
||||||
// Lastly, ensure this tx will pass the mempool's chain limits
|
// Lastly, ensure this tx will pass the mempool's chain limits
|
||||||
LockPoints lp;
|
if (!chain().checkChainLimits(tx)) {
|
||||||
CTxMemPoolEntry entry(tx, 0, 0, 0, false, 0, lp);
|
|
||||||
CTxMemPool::setEntries setAncestors;
|
|
||||||
size_t nLimitAncestors = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
|
|
||||||
size_t nLimitAncestorSize = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000;
|
|
||||||
size_t nLimitDescendants = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
|
|
||||||
size_t nLimitDescendantSize = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)*1000;
|
|
||||||
std::string errString;
|
|
||||||
LOCK(::mempool.cs);
|
|
||||||
if (!::mempool.CalculateMemPoolAncestors(entry, setAncestors, nLimitAncestors, nLimitAncestorSize, nLimitDescendants, nLimitDescendantSize, errString)) {
|
|
||||||
strFailReason = _("Transaction has too long of a mempool chain");
|
strFailReason = _("Transaction has too long of a mempool chain");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue