diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 845fbdb66e5..79b2b4ec94a 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -155,12 +155,12 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector& vHashes } util::Result CTxMemPool::CalculateAncestorsAndCheckLimits( - size_t entry_size, + int64_t entry_size, size_t entry_count, CTxMemPoolEntry::Parents& staged_ancestors, const Limits& limits) const { - size_t totalSizeWithAncestors = entry_size; + int64_t totalSizeWithAncestors = entry_size; setEntries ancestors; while (!staged_ancestors.empty()) { @@ -171,11 +171,11 @@ util::Result CTxMemPool::CalculateAncestorsAndCheckLimit staged_ancestors.erase(stage); totalSizeWithAncestors += stageit->GetTxSize(); - if (stageit->GetSizeWithDescendants() + entry_size > static_cast(limits.descendant_size_vbytes)) { + if (stageit->GetSizeWithDescendants() + entry_size > limits.descendant_size_vbytes) { return util::Error{Untranslated(strprintf("exceeds descendant size limit for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limits.descendant_size_vbytes))}; } else if (stageit->GetCountWithDescendants() + entry_count > static_cast(limits.descendant_count)) { return util::Error{Untranslated(strprintf("too many descendants for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limits.descendant_count))}; - } else if (totalSizeWithAncestors > static_cast(limits.ancestor_size_vbytes)) { + } else if (totalSizeWithAncestors > limits.ancestor_size_vbytes) { return util::Error{Untranslated(strprintf("exceeds ancestor size limit [limit: %u]", limits.ancestor_size_vbytes))}; } @@ -201,7 +201,7 @@ bool CTxMemPool::CheckPackageLimits(const Package& package, std::string &errString) const { CTxMemPoolEntry::Parents staged_ancestors; - size_t total_size = 0; + int64_t total_size = 0; for (const auto& tx : package) { total_size += GetVirtualTransactionSize(*tx); for (const auto& input : tx->vin) { diff --git a/src/txmempool.h b/src/txmempool.h index 846def02cd7..a1867eb895a 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -442,7 +442,7 @@ private: * * @return all in-mempool ancestors, or an error if any ancestor or descendant limits were hit */ - util::Result CalculateAncestorsAndCheckLimits(size_t entry_size, + util::Result CalculateAncestorsAndCheckLimits(int64_t entry_size, size_t entry_count, CTxMemPoolEntry::Parents &staged_ancestors, const Limits& limits