diff options
author | glozow <gloriajzhao@gmail.com> | 2023-08-03 11:45:44 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2023-08-03 11:45:51 +0100 |
commit | 7c66a4b6109c01b79979128ef23e63fc733f89ba (patch) | |
tree | ed0a19b3df11002e16bda3d025e664e43b91bf57 /src | |
parent | 532bd1f2e70eab14cd69ebad943806743b833f92 (diff) | |
parent | 92de74ef181b42d774bc6b12329bc0c27caf0081 (diff) | |
download | bitcoin-7c66a4b6109c01b79979128ef23e63fc733f89ba.tar.xz |
Merge bitcoin/bitcoin#28059: refactor: Make more transaction size variables signed
92de74ef181b42d774bc6b12329bc0c27caf0081 refactor: Make more transaction size variables signed (Hennadii Stepanov)
Pull request description:
This PR is a continuation of https://github.com/bitcoin/bitcoin/pull/23962 and it:
- gets rid of two static casts,
- addresses https://github.com/bitcoin/bitcoin/pull/23962#issuecomment-1593289706,
- is useful for https://github.com/bitcoin/bitcoin/pull/25972, see the failed ARM and multiprocess CI jobs.
ACKs for top commit:
MarcoFalke:
lgtm ACK 92de74ef181b42d774bc6b12329bc0c27caf0081 🥔
glozow:
ACK 92de74ef181b42d774bc6b12329bc0c27caf0081
Tree-SHA512: 84225961af8e08439664e75661b98fe86560217e891e5633a28316bf248d88df317a0c6b5a5f6b03feb2b0e0fd40a1f91dd4a85a0610d567470805bf47a84487
Diffstat (limited to 'src')
-rw-r--r-- | src/txmempool.cpp | 10 | ||||
-rw-r--r-- | src/txmempool.h | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 845fbdb66e..79b2b4ec94 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -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()) { @@ -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))}; } @@ -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 846def02cd..a1867eb895 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<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 |