Skip to content

Commit af5d18a

Browse files
laanwjcodablock
authored andcommitted
Merge bitcoin#8707: net: fix maxuploadtarget setting
f3552da net: fix maxuploadtarget setting (Cory Fields)
1 parent 699db99 commit af5d18a

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
@@ -1432,8 +1432,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
14321432
pdsNotificationInterface = new CDSNotificationInterface(connman);
14331433
RegisterValidationInterface(pdsNotificationInterface);
14341434

1435+
uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set
1436+
uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
1437+
14351438
if (mapArgs.count("-maxuploadtarget")) {
1436-
connman.SetMaxOutboundTarget(GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024);
1439+
nMaxOutboundLimit = GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024;
14371440
}
14381441

14391442
// ********************************************************* Step 7: load block chain
@@ -1847,6 +1850,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
18471850
connOptions.nSendBufferMaxSize = 1000*GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER);
18481851
connOptions.nReceiveFloodSize = 1000*GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
18491852

1853+
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
1854+
connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
1855+
18501856
if (!connman.Start(scheduler, strNodeError, connOptions))
18511857
return InitError(strNodeError);
18521858

src/net.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,9 +2153,7 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c
21532153
{
21542154
nTotalBytesRecv = 0;
21552155
nTotalBytesSent = 0;
2156-
nMaxOutboundLimit = 0;
21572156
nMaxOutboundTotalBytesSentInCycle = 0;
2158-
nMaxOutboundTimeframe = 60*60*24; //1 day
21592157
nMaxOutboundCycleStartTime = 0;
21602158

21612159
nRelevantServices = connOptions.nRelevantServices;
@@ -2167,6 +2165,9 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c
21672165
nSendBufferMaxSize = connOptions.nSendBufferMaxSize;
21682166
nReceiveFloodSize = connOptions.nReceiveFloodSize;
21692167

2168+
nMaxOutboundLimit = connOptions.nMaxOutboundLimit;
2169+
nMaxOutboundTimeframe = connOptions.nMaxOutboundTimeframe;
2170+
21702171
SetBestHeight(connOptions.nBestHeight);
21712172

21722173
clientInterface = connOptions.uiInterface;

src/net.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ static const size_t SETASKFOR_MAX_SZ = 2 * MAX_INV_SZ;
8080
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;
8181
/** The default for -maxuploadtarget. 0 = Unlimited */
8282
static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
83+
/** The default timeframe for -maxuploadtarget. 1 day. */
84+
static const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24;
8385
/** Default for blocks only*/
8486
static const bool DEFAULT_BLOCKSONLY = false;
8587

@@ -128,6 +130,8 @@ class CConnman
128130
CClientUIInterface* uiInterface = nullptr;
129131
unsigned int nSendBufferMaxSize = 0;
130132
unsigned int nReceiveFloodSize = 0;
133+
uint64_t nMaxOutboundTimeframe = 0;
134+
uint64_t nMaxOutboundLimit = 0;
131135
};
132136
CConnman();
133137
~CConnman();

0 commit comments

Comments
 (0)