Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#28059: refactor: Make more transaction size var…
Browse files Browse the repository at this point in the history
…iables signed

92de74e refactor: Make more transaction size variables signed (Hennadii Stepanov)

Pull request description:

  This PR is a continuation of bitcoin/bitcoin#23962 and it:
  - gets rid of two static casts,
  - addresses bitcoin/bitcoin#23962 (comment),
  - is useful for bitcoin/bitcoin#25972, see the failed ARM and multiprocess CI jobs.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 92de74e  🥔
  glozow:
    ACK 92de74e

Tree-SHA512: 84225961af8e08439664e75661b98fe86560217e891e5633a28316bf248d88df317a0c6b5a5f6b03feb2b0e0fd40a1f91dd4a85a0610d567470805bf47a84487
  • Loading branch information
glozow committed Aug 3, 2023
2 parents 532bd1f + 92de74e commit 7c66a4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256>& vHashes
}

util::Result<CTxMemPool::setEntries> 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()) {
Expand All @@ -171,11 +171,11 @@ util::Result<CTxMemPool::setEntries> CTxMemPool::CalculateAncestorsAndCheckLimit
staged_ancestors.erase(stage);
totalSizeWithAncestors += stageit->GetTxSize();

if (stageit->GetSizeWithDescendants() + entry_size > static_cast<uint64_t>(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<uint64_t>(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<uint64_t>(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))};
}

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class CTxMemPool
*
* @return all in-mempool ancestors, or an error if any ancestor or descendant limits were hit
*/
util::Result<setEntries> CalculateAncestorsAndCheckLimits(size_t entry_size,
util::Result<setEntries> CalculateAncestorsAndCheckLimits(int64_t entry_size,
size_t entry_count,
CTxMemPoolEntry::Parents &staged_ancestors,
const Limits& limits
Expand Down

0 comments on commit 7c66a4b

Please sign in to comment.