@@ -73,7 +73,7 @@ static constexpr std::chrono::minutes DNSSEEDS_DELAY_MANY_PEERS{5};
73
73
static constexpr int DNSSEEDS_DELAY_PEER_THRESHOLD = 1000 ; // "many" vs "few" peers
74
74
75
75
/* * The default timeframe for -maxuploadtarget. 1 day. */
76
- static constexpr uint64_t MAX_UPLOAD_TIMEFRAME = 60 * 60 * 24 ;
76
+ static constexpr std::chrono::seconds MAX_UPLOAD_TIMEFRAME{ 60 * 60 * 24 } ;
77
77
78
78
// We add a random period time (0 to 1 seconds) to feeler connections to prevent synchronization.
79
79
#define FEELER_SLEEP_WINDOW 1
@@ -2850,7 +2850,7 @@ void CConnman::RecordBytesSent(uint64_t bytes)
2850
2850
LOCK (cs_totalBytesSent);
2851
2851
nTotalBytesSent += bytes;
2852
2852
2853
- uint64_t now = GetTime ();
2853
+ const auto now = GetTime<std::chrono::seconds> ();
2854
2854
if (nMaxOutboundCycleStartTime + MAX_UPLOAD_TIMEFRAME < now)
2855
2855
{
2856
2856
// timeframe expired, reset cycle
@@ -2868,23 +2868,23 @@ uint64_t CConnman::GetMaxOutboundTarget()
2868
2868
return nMaxOutboundLimit;
2869
2869
}
2870
2870
2871
- uint64_t CConnman::GetMaxOutboundTimeframe ()
2871
+ std::chrono::seconds CConnman::GetMaxOutboundTimeframe ()
2872
2872
{
2873
2873
return MAX_UPLOAD_TIMEFRAME;
2874
2874
}
2875
2875
2876
- uint64_t CConnman::GetMaxOutboundTimeLeftInCycle ()
2876
+ std::chrono::seconds CConnman::GetMaxOutboundTimeLeftInCycle ()
2877
2877
{
2878
2878
LOCK (cs_totalBytesSent);
2879
2879
if (nMaxOutboundLimit == 0 )
2880
- return 0 ;
2880
+ return 0s ;
2881
2881
2882
- if (nMaxOutboundCycleStartTime == 0 )
2882
+ if (nMaxOutboundCycleStartTime. count () == 0 )
2883
2883
return MAX_UPLOAD_TIMEFRAME;
2884
2884
2885
- uint64_t cycleEndTime = nMaxOutboundCycleStartTime + MAX_UPLOAD_TIMEFRAME;
2886
- uint64_t now = GetTime ();
2887
- return (cycleEndTime < now) ? 0 : cycleEndTime - GetTime () ;
2885
+ const std::chrono::seconds cycleEndTime = nMaxOutboundCycleStartTime + MAX_UPLOAD_TIMEFRAME;
2886
+ const auto now = GetTime<std::chrono::seconds> ();
2887
+ return (cycleEndTime < now) ? 0s : cycleEndTime - now ;
2888
2888
}
2889
2889
2890
2890
bool CConnman::OutboundTargetReached (bool historicalBlockServingLimit)
@@ -2896,8 +2896,8 @@ bool CConnman::OutboundTargetReached(bool historicalBlockServingLimit)
2896
2896
if (historicalBlockServingLimit)
2897
2897
{
2898
2898
// keep a large enough buffer to at least relay each block once
2899
- uint64_t timeLeftInCycle = GetMaxOutboundTimeLeftInCycle ();
2900
- uint64_t buffer = timeLeftInCycle / 600 * MAX_BLOCK_SERIALIZED_SIZE;
2899
+ const std::chrono::seconds timeLeftInCycle = GetMaxOutboundTimeLeftInCycle ();
2900
+ const uint64_t buffer = timeLeftInCycle / std::chrono::minutes{ 10 } * MAX_BLOCK_SERIALIZED_SIZE;
2901
2901
if (buffer >= nMaxOutboundLimit || nMaxOutboundTotalBytesSentInCycle >= nMaxOutboundLimit - buffer)
2902
2902
return true ;
2903
2903
}
0 commit comments