Skip to content

Commit 547fa52

Browse files
committed
net processing: clamp -blockreconstructionextratxn to uint32_t bounds
Also changes max_extra_txs into a uint32_t to avoid platform-specific behaviour
1 parent e451d1e commit 547fa52

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/net_processing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false};
2020
static const uint32_t DEFAULT_MAX_ORPHAN_TRANSACTIONS{100};
2121
/** Default number of non-mempool transactions to keep around for block reconstruction. Includes
2222
orphan, replaced, and rejected transactions. */
23-
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
23+
static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100};
2424
static const bool DEFAULT_PEERBLOOMFILTERS = false;
2525
static const bool DEFAULT_PEERBLOCKFILTERS = false;
2626
/** Threshold for marking a node to be discouraged, e.g. disconnected and added to the discouragement filter. */
@@ -55,7 +55,7 @@ class PeerManager : public CValidationInterface, public NetEventsInterface
5555
uint32_t max_orphan_txs{DEFAULT_MAX_ORPHAN_TRANSACTIONS};
5656
//! Number of non-mempool transactions to keep around for block reconstruction. Includes
5757
//! orphan, replaced, and rejected transactions.
58-
size_t max_extra_txs{DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN};
58+
uint32_t max_extra_txs{DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN};
5959
//! Whether all P2P messages are captured to disk
6060
bool capture_messages{false};
6161
};

src/node/peerman_args.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void ApplyArgsManOptions(const ArgsManager& argsman, PeerManager::Options& optio
1717
}
1818

1919
if (auto value{argsman.GetIntArg("-blockreconstructionextratxn")}) {
20-
options.max_extra_txs = size_t(std::max(int64_t{0}, *value));
20+
options.max_extra_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max())));
2121
}
2222

2323
if (auto value{argsman.GetBoolArg("-capturemessages")}) options.capture_messages = *value;

0 commit comments

Comments
 (0)