Skip to content

Commit e451d1e

Browse files
committed
net processing: clamp -maxorphantx to uint32_t bounds
1 parent aa89e04 commit e451d1e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/net_processing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ChainstateManager;
1717
/** Whether transaction reconciliation protocol should be enabled by default. */
1818
static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false};
1919
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
20-
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
20+
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. */
2323
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;

src/node/peerman_args.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
#include <common/args.h>
44
#include <net_processing.h>
55

6+
#include <algorithm>
7+
#include <limits>
8+
69
namespace node {
710

811
void ApplyArgsManOptions(const ArgsManager& argsman, PeerManager::Options& options)
912
{
1013
if (auto value{argsman.GetBoolArg("-txreconciliation")}) options.reconcile_txs = *value;
1114

1215
if (auto value{argsman.GetIntArg("-maxorphantx")}) {
13-
options.max_orphan_txs = uint32_t(std::max(int64_t{0}, *value));
16+
options.max_orphan_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max())));
1417
}
1518

1619
if (auto value{argsman.GetIntArg("-blockreconstructionextratxn")}) {

0 commit comments

Comments
 (0)