Skip to content

Commit 70d2293

Browse files
ismaelsadeeqTom Trevethan
authored andcommitted
miner: fix addPackageTxs unsigned integer overflow
1 parent 98bd718 commit 70d2293

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/node/miner.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
392392
// close to full; this is just a simple heuristic to finish quickly if the
393393
// mempool has a lot of entries.
394394
const int64_t MAX_CONSECUTIVE_FAILURES = 1000;
395+
constexpr int32_t BLOCK_FULL_ENOUGH_WEIGHT_DELTA = 4000;
395396
int64_t nConsecutiveFailed = 0;
396397

397398
while (mi != m_mempool.mapTx.get<confidential_score>().end() || !mapModifiedTx.empty()) {
@@ -471,8 +472,8 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
471472

472473
++nConsecutiveFailed;
473474

474-
if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight >
475-
nBlockMaxWeight - 4000) {
475+
if (nConsecutiveFailed > MAX_CONSECUTIVE_FAILURES && nBlockWeight +
476+
BLOCK_FULL_ENOUGH_WEIGHT_DELTA > nBlockMaxWeight) {
476477
// Give up if we're close to full and haven't succeeded in a while
477478
break;
478479
}

0 commit comments

Comments
 (0)