aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2020-10-24 16:38:56 +0800
committerfanquake <fanquake@gmail.com>2020-12-13 11:12:05 +0800
commitf805933e70d4320e62739f4cecfc08bdbad8afaa (patch)
treebd063a646c19430534f2bbbf53405861c90dabf2
parent173d0d35f1bb271175047c9eb7dd58cc46ed35bf (diff)
init: set nMaxOutboundLimit connection option directly
DEFAULT_MAX_UPLOAD_TARGET is a compile time constant.
-rw-r--r--src/init.cpp7
-rw-r--r--src/net.h2
2 files changed, 2 insertions, 7 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 7823f96c90..48711f9cd2 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1513,11 +1513,6 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
RegisterValidationInterface(g_zmq_notification_interface);
}
#endif
- uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set
-
- if (args.IsArgSet("-maxuploadtarget")) {
- nMaxOutboundLimit = args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET) * 1024 * 1024;
- }
// ********************************************************* Step 7: load block chain
@@ -1920,7 +1915,7 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
connOptions.nReceiveFloodSize = 1000 * args.GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
connOptions.m_added_nodes = args.GetArgs("-addnode");
- connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
+ connOptions.nMaxOutboundLimit = 1024 * 1024 * args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET);
connOptions.m_peer_connect_timeout = peer_connect_timeout;
for (const std::string& bind_arg : args.GetArgs("-bind")) {
diff --git a/src/net.h b/src/net.h
index 31141d96c2..1b9722fc27 100644
--- a/src/net.h
+++ b/src/net.h
@@ -75,7 +75,7 @@ static const bool DEFAULT_UPNP = false;
/** The maximum number of peer connections to maintain. */
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;
/** The default for -maxuploadtarget. 0 = Unlimited */
-static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
+static constexpr uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
/** Default for blocks only*/
static const bool DEFAULT_BLOCKSONLY = false;
/** -peertimeout default */