mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-03 12:04:15 +00:00
update congestion caps before initial publishing
This commit is contained in:
parent
f990a2f69f
commit
43f5ba286c
@ -1330,7 +1330,10 @@ namespace i2p
|
|||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
{
|
{
|
||||||
if (m_RouterInfo.IsReachableBy (i2p::data::RouterInfo::eAllTransports))
|
if (m_RouterInfo.IsReachableBy (i2p::data::RouterInfo::eAllTransports))
|
||||||
|
{
|
||||||
|
UpdateCongestion ();
|
||||||
HandlePublishTimer (ecode);
|
HandlePublishTimer (ecode);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateTimestamp (i2p::util::GetSecondsSinceEpoch ());
|
UpdateTimestamp (i2p::util::GetSecondsSinceEpoch ());
|
||||||
@ -1469,23 +1472,28 @@ namespace i2p
|
|||||||
{
|
{
|
||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
{
|
{
|
||||||
auto c = i2p::data::RouterInfo::eLowCongestion;
|
UpdateCongestion ();
|
||||||
if (!AcceptsTunnels () || !m_ShareRatio)
|
|
||||||
c = i2p::data::RouterInfo::eRejectAll;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int congestionLevel = GetCongestionLevel (true);
|
|
||||||
if (congestionLevel > CONGESTION_LEVEL_HIGH)
|
|
||||||
c = i2p::data::RouterInfo::eHighCongestion;
|
|
||||||
else if (congestionLevel > CONGESTION_LEVEL_MEDIUM)
|
|
||||||
c = i2p::data::RouterInfo::eMediumCongestion;
|
|
||||||
}
|
|
||||||
if (m_RouterInfo.UpdateCongestion (c))
|
|
||||||
UpdateRouterInfo ();
|
|
||||||
ScheduleCongestionUpdate ();
|
ScheduleCongestionUpdate ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterContext::UpdateCongestion ()
|
||||||
|
{
|
||||||
|
auto c = i2p::data::RouterInfo::eLowCongestion;
|
||||||
|
if (!AcceptsTunnels () || !m_ShareRatio)
|
||||||
|
c = i2p::data::RouterInfo::eRejectAll;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int congestionLevel = GetCongestionLevel (true);
|
||||||
|
if (congestionLevel > CONGESTION_LEVEL_HIGH)
|
||||||
|
c = i2p::data::RouterInfo::eHighCongestion;
|
||||||
|
else if (congestionLevel > CONGESTION_LEVEL_MEDIUM)
|
||||||
|
c = i2p::data::RouterInfo::eMediumCongestion;
|
||||||
|
}
|
||||||
|
if (m_RouterInfo.UpdateCongestion (c))
|
||||||
|
UpdateRouterInfo ();
|
||||||
|
}
|
||||||
|
|
||||||
void RouterContext::ScheduleCleanupTimer ()
|
void RouterContext::ScheduleCleanupTimer ()
|
||||||
{
|
{
|
||||||
if (m_CleanupTimer)
|
if (m_CleanupTimer)
|
||||||
|
@ -230,6 +230,7 @@ namespace garlic
|
|||||||
void HandlePublishResendTimer (const boost::system::error_code& ecode);
|
void HandlePublishResendTimer (const boost::system::error_code& ecode);
|
||||||
void ScheduleCongestionUpdate ();
|
void ScheduleCongestionUpdate ();
|
||||||
void HandleCongestionUpdateTimer (const boost::system::error_code& ecode);
|
void HandleCongestionUpdateTimer (const boost::system::error_code& ecode);
|
||||||
|
void UpdateCongestion ();
|
||||||
void ScheduleCleanupTimer ();
|
void ScheduleCleanupTimer ();
|
||||||
void HandleCleanupTimer (const boost::system::error_code& ecode);
|
void HandleCleanupTimer (const boost::system::error_code& ecode);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user