Skip to content

Commit 1a579f9

Browse files
committed
Handle over-sized (in virtual bytes) packages with no in-mempool ancestors
1 parent bc013fe commit 1a579f9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/txmempool.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@ bool CTxMemPool::CheckPackageLimits(const Package& package,
200200
const int64_t total_vsize,
201201
std::string &errString) const
202202
{
203+
size_t pack_count = package.size();
204+
205+
// Package itself is busting mempool limits; should be rejected even if no staged_ancestors exist
206+
if (pack_count > static_cast<uint64_t>(m_limits.ancestor_count)) {
207+
errString = strprintf("package count %u exceeds ancestor count limit [limit: %u]", pack_count, m_limits.ancestor_count);
208+
return false;
209+
} else if (pack_count > static_cast<uint64_t>(m_limits.descendant_count)) {
210+
errString = strprintf("package count %u exceeds descendant count limit [limit: %u]", pack_count, m_limits.descendant_count);
211+
return false;
212+
} else if (total_vsize > m_limits.ancestor_size_vbytes) {
213+
errString = strprintf("package size %u exceeds ancestor size limit [limit: %u]", total_vsize, m_limits.ancestor_size_vbytes);
214+
return false;
215+
} else if (total_vsize > m_limits.descendant_size_vbytes) {
216+
errString = strprintf("package size %u exceeds descendant size limit [limit: %u]", total_vsize, m_limits.descendant_size_vbytes);
217+
return false;
218+
}
219+
203220
CTxMemPoolEntry::Parents staged_ancestors;
204221
for (const auto& tx : package) {
205222
for (const auto& input : tx->vin) {

0 commit comments

Comments
 (0)