Skip to content

Commit 7c66a4b

Browse files
committed
Merge bitcoin/bitcoin#28059: refactor: Make more transaction size variables 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
2 parents 532bd1f + 92de74e commit 7c66a4b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/txmempool.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256>& vHashes
155155
}
156156

157157
util::Result<CTxMemPool::setEntries> CTxMemPool::CalculateAncestorsAndCheckLimits(
158-
size_t entry_size,
158+
int64_t entry_size,
159159
size_t entry_count,
160160
CTxMemPoolEntry::Parents& staged_ancestors,
161161
const Limits& limits) const
162162
{
163-
size_t totalSizeWithAncestors = entry_size;
163+
int64_t totalSizeWithAncestors = entry_size;
164164
setEntries ancestors;
165165

166166
while (!staged_ancestors.empty()) {
@@ -171,11 +171,11 @@ util::Result<CTxMemPool::setEntries> CTxMemPool::CalculateAncestorsAndCheckLimit
171171
staged_ancestors.erase(stage);
172172
totalSizeWithAncestors += stageit->GetTxSize();
173173

174-
if (stageit->GetSizeWithDescendants() + entry_size > static_cast<uint64_t>(limits.descendant_size_vbytes)) {
174+
if (stageit->GetSizeWithDescendants() + entry_size > limits.descendant_size_vbytes) {
175175
return util::Error{Untranslated(strprintf("exceeds descendant size limit for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limits.descendant_size_vbytes))};
176176
} else if (stageit->GetCountWithDescendants() + entry_count > static_cast<uint64_t>(limits.descendant_count)) {
177177
return util::Error{Untranslated(strprintf("too many descendants for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limits.descendant_count))};
178-
} else if (totalSizeWithAncestors > static_cast<uint64_t>(limits.ancestor_size_vbytes)) {
178+
} else if (totalSizeWithAncestors > limits.ancestor_size_vbytes) {
179179
return util::Error{Untranslated(strprintf("exceeds ancestor size limit [limit: %u]", limits.ancestor_size_vbytes))};
180180
}
181181

@@ -201,7 +201,7 @@ bool CTxMemPool::CheckPackageLimits(const Package& package,
201201
std::string &errString) const
202202
{
203203
CTxMemPoolEntry::Parents staged_ancestors;
204-
size_t total_size = 0;
204+
int64_t total_size = 0;
205205
for (const auto& tx : package) {
206206
total_size += GetVirtualTransactionSize(*tx);
207207
for (const auto& input : tx->vin) {

src/txmempool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ class CTxMemPool
442442
*
443443
* @return all in-mempool ancestors, or an error if any ancestor or descendant limits were hit
444444
*/
445-
util::Result<setEntries> CalculateAncestorsAndCheckLimits(size_t entry_size,
445+
util::Result<setEntries> CalculateAncestorsAndCheckLimits(int64_t entry_size,
446446
size_t entry_count,
447447
CTxMemPoolEntry::Parents &staged_ancestors,
448448
const Limits& limits

0 commit comments

Comments
 (0)