Skip to content

Commit f07424a

Browse files
committed
Merge #8707: net: fix maxuploadtarget setting
f3552da net: fix maxuploadtarget setting (Cory Fields)
2 parents 9ac0130 + f3552da commit f07424a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/init.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,8 +1249,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12491249
RegisterValidationInterface(pzmqNotificationInterface);
12501250
}
12511251
#endif
1252+
uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set
1253+
uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
1254+
12521255
if (mapArgs.count("-maxuploadtarget")) {
1253-
connman.SetMaxOutboundTarget(GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024);
1256+
nMaxOutboundLimit = GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024;
12541257
}
12551258

12561259
// ********************************************************* Step 7: load block chain
@@ -1533,6 +1536,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
15331536
connOptions.nSendBufferMaxSize = 1000*GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER);
15341537
connOptions.nReceiveFloodSize = 1000*GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
15351538

1539+
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
1540+
connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
1541+
15361542
if(!connman.Start(threadGroup, scheduler, strNodeError, connOptions))
15371543
return InitError(strNodeError);
15381544

src/net.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,9 +2046,7 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, st
20462046
{
20472047
nTotalBytesRecv = 0;
20482048
nTotalBytesSent = 0;
2049-
nMaxOutboundLimit = 0;
20502049
nMaxOutboundTotalBytesSentInCycle = 0;
2051-
nMaxOutboundTimeframe = 60*60*24; //1 day
20522050
nMaxOutboundCycleStartTime = 0;
20532051

20542052
nRelevantServices = connOptions.nRelevantServices;
@@ -2060,6 +2058,9 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, st
20602058
nSendBufferMaxSize = connOptions.nSendBufferMaxSize;
20612059
nReceiveFloodSize = connOptions.nSendBufferMaxSize;
20622060

2061+
nMaxOutboundLimit = connOptions.nMaxOutboundLimit;
2062+
nMaxOutboundTimeframe = connOptions.nMaxOutboundTimeframe;
2063+
20632064
SetBestHeight(connOptions.nBestHeight);
20642065

20652066
clientInterface = connOptions.uiInterface;

src/net.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ static const size_t SETASKFOR_MAX_SZ = 2 * MAX_INV_SZ;
7272
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;
7373
/** The default for -maxuploadtarget. 0 = Unlimited */
7474
static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
75+
/** The default timeframe for -maxuploadtarget. 1 day. */
76+
static const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24;
7577
/** Default for blocks only*/
7678
static const bool DEFAULT_BLOCKSONLY = false;
7779

@@ -120,6 +122,8 @@ class CConnman
120122
CClientUIInterface* uiInterface = nullptr;
121123
unsigned int nSendBufferMaxSize = 0;
122124
unsigned int nReceiveFloodSize = 0;
125+
uint64_t nMaxOutboundTimeframe = 0;
126+
uint64_t nMaxOutboundLimit = 0;
123127
};
124128
CConnman();
125129
~CConnman();

0 commit comments

Comments
 (0)