diff options
-rw-r--r-- | src/net_processing.h | 2 | ||||
-rw-r--r-- | src/node/peerman_args.cpp | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/net_processing.h b/src/net_processing.h index b1e6e4eebb..619bf6220d 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -17,7 +17,7 @@ class ChainstateManager; /** Whether transaction reconciliation protocol should be enabled by default. */ static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false}; /** Default for -maxorphantx, maximum number of orphan transactions kept in memory */ -static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100; +static const uint32_t DEFAULT_MAX_ORPHAN_TRANSACTIONS{100}; /** Default number of non-mempool transactions to keep around for block reconstruction. Includes orphan, replaced, and rejected transactions. */ static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100; diff --git a/src/node/peerman_args.cpp b/src/node/peerman_args.cpp index e5868ead12..1a70ce96f1 100644 --- a/src/node/peerman_args.cpp +++ b/src/node/peerman_args.cpp @@ -3,6 +3,9 @@ #include <common/args.h> #include <net_processing.h> +#include <algorithm> +#include <limits> + namespace node { void ApplyArgsManOptions(const ArgsManager& argsman, PeerManager::Options& options) @@ -10,7 +13,7 @@ void ApplyArgsManOptions(const ArgsManager& argsman, PeerManager::Options& optio if (auto value{argsman.GetBoolArg("-txreconciliation")}) options.reconcile_txs = *value; if (auto value{argsman.GetIntArg("-maxorphantx")}) { - options.max_orphan_txs = uint32_t(std::max(int64_t{0}, *value)); + options.max_orphan_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max()))); } if (auto value{argsman.GetIntArg("-blockreconstructionextratxn")}) { |