Skip to content

Commit 173d0d3

Browse files
committed
net: remove nMaxOutboundTimeframe from connection options
It's not actually possible to change this value, so remove the indirection of it being a conn option. DEFAULT_MAX_UPLOAD_TIMEFRAME is a compile time constant.
1 parent b117eb1 commit 173d0d3

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

src/init.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,6 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
15141514
}
15151515
#endif
15161516
uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set
1517-
uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
15181517

15191518
if (args.IsArgSet("-maxuploadtarget")) {
15201519
nMaxOutboundLimit = args.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET) * 1024 * 1024;
@@ -1921,7 +1920,6 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
19211920
connOptions.nReceiveFloodSize = 1000 * args.GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
19221921
connOptions.m_added_nodes = args.GetArgs("-addnode");
19231922

1924-
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
19251923
connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
19261924
connOptions.m_peer_connect_timeout = peer_connect_timeout;
19271925

src/net.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ static constexpr std::chrono::seconds DNSSEEDS_DELAY_FEW_PEERS{11};
7272
static constexpr std::chrono::minutes DNSSEEDS_DELAY_MANY_PEERS{5};
7373
static constexpr int DNSSEEDS_DELAY_PEER_THRESHOLD = 1000; // "many" vs "few" peers
7474

75+
/** The default timeframe for -maxuploadtarget. 1 day. */
76+
static constexpr uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24;
77+
7578
// We add a random period time (0 to 1 seconds) to feeler connections to prevent synchronization.
7679
#define FEELER_SLEEP_WINDOW 1
7780

@@ -2848,7 +2851,7 @@ void CConnman::RecordBytesSent(uint64_t bytes)
28482851
nTotalBytesSent += bytes;
28492852

28502853
uint64_t now = GetTime();
2851-
if (nMaxOutboundCycleStartTime + nMaxOutboundTimeframe < now)
2854+
if (nMaxOutboundCycleStartTime + MAX_UPLOAD_TIMEFRAME < now)
28522855
{
28532856
// timeframe expired, reset cycle
28542857
nMaxOutboundCycleStartTime = now;
@@ -2867,8 +2870,7 @@ uint64_t CConnman::GetMaxOutboundTarget()
28672870

28682871
uint64_t CConnman::GetMaxOutboundTimeframe()
28692872
{
2870-
LOCK(cs_totalBytesSent);
2871-
return nMaxOutboundTimeframe;
2873+
return MAX_UPLOAD_TIMEFRAME;
28722874
}
28732875

28742876
uint64_t CConnman::GetMaxOutboundTimeLeftInCycle()
@@ -2878,9 +2880,9 @@ uint64_t CConnman::GetMaxOutboundTimeLeftInCycle()
28782880
return 0;
28792881

28802882
if (nMaxOutboundCycleStartTime == 0)
2881-
return nMaxOutboundTimeframe;
2883+
return MAX_UPLOAD_TIMEFRAME;
28822884

2883-
uint64_t cycleEndTime = nMaxOutboundCycleStartTime + nMaxOutboundTimeframe;
2885+
uint64_t cycleEndTime = nMaxOutboundCycleStartTime + MAX_UPLOAD_TIMEFRAME;
28842886
uint64_t now = GetTime();
28852887
return (cycleEndTime < now) ? 0 : cycleEndTime - GetTime();
28862888
}

src/net.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ static const bool DEFAULT_UPNP = false;
7676
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;
7777
/** The default for -maxuploadtarget. 0 = Unlimited */
7878
static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
79-
/** The default timeframe for -maxuploadtarget. 1 day. */
80-
static const uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24;
8179
/** Default for blocks only*/
8280
static const bool DEFAULT_BLOCKSONLY = false;
8381
/** -peertimeout default */
@@ -207,7 +205,6 @@ class CConnman
207205
BanMan* m_banman = nullptr;
208206
unsigned int nSendBufferMaxSize = 0;
209207
unsigned int nReceiveFloodSize = 0;
210-
uint64_t nMaxOutboundTimeframe = 0;
211208
uint64_t nMaxOutboundLimit = 0;
212209
int64_t m_peer_connect_timeout = DEFAULT_PEER_CONNECT_TIMEOUT;
213210
std::vector<std::string> vSeedNodes;
@@ -239,7 +236,6 @@ class CConnman
239236
m_peer_connect_timeout = connOptions.m_peer_connect_timeout;
240237
{
241238
LOCK(cs_totalBytesSent);
242-
nMaxOutboundTimeframe = connOptions.nMaxOutboundTimeframe;
243239
nMaxOutboundLimit = connOptions.nMaxOutboundLimit;
244240
}
245241
vWhitelistedRange = connOptions.vWhitelistedRange;
@@ -481,7 +477,6 @@ class CConnman
481477
uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY(cs_totalBytesSent) {0};
482478
uint64_t nMaxOutboundCycleStartTime GUARDED_BY(cs_totalBytesSent) {0};
483479
uint64_t nMaxOutboundLimit GUARDED_BY(cs_totalBytesSent);
484-
uint64_t nMaxOutboundTimeframe GUARDED_BY(cs_totalBytesSent);
485480

486481
// P2P timeout in seconds
487482
int64_t m_peer_connect_timeout;

0 commit comments

Comments
 (0)