Skip to content

Commit 166bc34

Browse files
committed
Merge #1525: miner: fix addPackageTxs unsigned integer overflow
70d2293 miner: fix `addPackageTxs` unsigned integer overflow (ismaelsadeeq) Pull request description: Cherry-pick of bitcoin/bitcoin#33475 ACKs for top commit: delta1: ACK 70d2293; ran tests locally Tree-SHA512: e9e470fe4ceccd282bc12e942cfde4e3b1c6abfa9747df93a4975c58ac17ff1266f26d35b1bc5b4887e8b6dfdba3380d67144ae35f2ee1489fa355ab211f2fc5
2 parents 720238c + 70d2293 commit 166bc34

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)