update congestion caps before initial publishing

This commit is contained in:
orignal 2024-06-09 15:25:19 -04:00
parent f990a2f69f
commit 43f5ba286c
2 changed files with 22 additions and 13 deletions

View file

@ -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 ());
@ -1468,6 +1471,13 @@ namespace i2p
void RouterContext::HandleCongestionUpdateTimer (const boost::system::error_code& ecode) void RouterContext::HandleCongestionUpdateTimer (const boost::system::error_code& ecode)
{ {
if (ecode != boost::asio::error::operation_aborted) if (ecode != boost::asio::error::operation_aborted)
{
UpdateCongestion ();
ScheduleCongestionUpdate ();
}
}
void RouterContext::UpdateCongestion ()
{ {
auto c = i2p::data::RouterInfo::eLowCongestion; auto c = i2p::data::RouterInfo::eLowCongestion;
if (!AcceptsTunnels () || !m_ShareRatio) if (!AcceptsTunnels () || !m_ShareRatio)
@ -1482,8 +1492,6 @@ namespace i2p
} }
if (m_RouterInfo.UpdateCongestion (c)) if (m_RouterInfo.UpdateCongestion (c))
UpdateRouterInfo (); UpdateRouterInfo ();
ScheduleCongestionUpdate ();
}
} }
void RouterContext::ScheduleCleanupTimer () void RouterContext::ScheduleCleanupTimer ()

View file

@ -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);