Skip to content

Commit 92de74e

Browse files
committed
refactor: Make more transaction size variables signed
This change gets rid of `static_cast`s and compiler warnings.
1 parent d23fda0 commit 92de74e

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)