diff options
author | Greg Sanders <gsanders87@gmail.com> | 2023-09-11 09:55:39 -0400 |
---|---|---|
committer | Greg Sanders <gsanders87@gmail.com> | 2023-09-20 10:34:09 -0400 |
commit | 1a579f9d01256b0b2570168496d129a8b2009b35 (patch) | |
tree | c0e278acbdce40a6d82b16ea6f4ed0ecc0935286 /src/txmempool.cpp | |
parent | bc013fe8e3d0bae2ab766a8248219aa3c9e344df (diff) |
Handle over-sized (in virtual bytes) packages with no in-mempool ancestors
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 960be428c6..e021cfb06e 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -200,6 +200,23 @@ bool CTxMemPool::CheckPackageLimits(const Package& package, const int64_t total_vsize, std::string &errString) const { + size_t pack_count = package.size(); + + // Package itself is busting mempool limits; should be rejected even if no staged_ancestors exist + if (pack_count > static_cast<uint64_t>(m_limits.ancestor_count)) { + errString = strprintf("package count %u exceeds ancestor count limit [limit: %u]", pack_count, m_limits.ancestor_count); + return false; + } else if (pack_count > static_cast<uint64_t>(m_limits.descendant_count)) { + errString = strprintf("package count %u exceeds descendant count limit [limit: %u]", pack_count, m_limits.descendant_count); + return false; + } else if (total_vsize > m_limits.ancestor_size_vbytes) { + errString = strprintf("package size %u exceeds ancestor size limit [limit: %u]", total_vsize, m_limits.ancestor_size_vbytes); + return false; + } else if (total_vsize > m_limits.descendant_size_vbytes) { + errString = strprintf("package size %u exceeds descendant size limit [limit: %u]", total_vsize, m_limits.descendant_size_vbytes); + return false; + } + CTxMemPoolEntry::Parents staged_ancestors; for (const auto& tx : package) { for (const auto& input : tx->vin) { |