aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-09-12 15:04:20 -0400
committerCory Fields <cory-nospam-@coryfields.com>2016-09-14 13:14:04 -0400
commitf3552da81393a8e78ce3e2afed0b9c9d1ff5cee0 (patch)
tree84ba797f7f67e1790d156b3425648249c446bcf2
parenta82e5d8220bbc8b5d786bed99b0876f530b9b7cc (diff)
downloadbitcoin-f3552da81393a8e78ce3e2afed0b9c9d1ff5cee0.tar.xz
net: fix maxuploadtarget setting
This was broken by 63cafa6329e1a. Note that while this fixes the settings, it doesn't fix the actual usage of -maxuploadtarget completely, as there is currently a bug in the nOptimisticBytesWritten accounting that causes a delayed response if the target is reached. That bug will be addressed separately.
-rw-r--r--src/init.cpp8
-rw-r--r--src/net.cpp5
-rw-r--r--src/net.h4
3 files changed, 14 insertions, 3 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 8d1e330a05..dd3fbf8502 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1249,8 +1249,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
RegisterValidationInterface(pzmqNotificationInterface);
}
#endif
+ uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set
+ uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
+
if (mapArgs.count("-maxuploadtarget")) {
- connman.SetMaxOutboundTarget(GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024);
+ nMaxOutboundLimit = GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024;
}
// ********************************************************* Step 7: load block chain
@@ -1533,6 +1536,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
connOptions.nSendBufferMaxSize = 1000*GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER);
connOptions.nReceiveFloodSize = 1000*GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
+ connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
+ connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
+
if(!connman.Start(threadGroup, scheduler, strNodeError, connOptions))
return InitError(strNodeError);
diff --git a/src/net.cpp b/src/net.cpp
index cc9728b853..ac64b28ea8 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2046,9 +2046,7 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, st
{
nTotalBytesRecv = 0;
nTotalBytesSent = 0;
- nMaxOutboundLimit = 0;
nMaxOutboundTotalBytesSentInCycle = 0;
- nMaxOutboundTimeframe = 60*60*24; //1 day
nMaxOutboundCycleStartTime = 0;
nRelevantServices = connOptions.nRelevantServices;
@@ -2060,6 +2058,9 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, st
nSendBufferMaxSize = connOptions.nSendBufferMaxSize;
nReceiveFloodSize = connOptions.nSendBufferMaxSize;
+ nMaxOutboundLimit = connOptions.nMaxOutboundLimit;
+ nMaxOutboundTimeframe = connOptions.nMaxOutboundTimeframe;
+
SetBestHeight(connOptions.nBestHeight);
clientInterface = connOptions.uiInterface;
diff --git a/src/net.h b/src/net.h
index a48ee02c44..dbed8b3dd5 100644
--- a/src/net.h
+++ b/src/net.h
@@ -72,6 +72,8 @@ static const size_t SETASKFOR_MAX_SZ = 2 * MAX_INV_SZ;
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;
/** The default for -maxuploadtarget. 0 = Unlimited */
static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
+/** The default timeframe for -maxuploadtarget. 1 day. */
+static const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24;
/** Default for blocks only*/
static const bool DEFAULT_BLOCKSONLY = false;
@@ -120,6 +122,8 @@ public:
CClientUIInterface* uiInterface = nullptr;
unsigned int nSendBufferMaxSize = 0;
unsigned int nReceiveFloodSize = 0;
+ uint64_t nMaxOutboundTimeframe = 0;
+ uint64_t nMaxOutboundLimit = 0;
};
CConnman();
~CConnman();