1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-30 12:04:13 +00:00

publish congestion cap G

This commit is contained in:
orignal 2023-04-02 11:27:51 -04:00
parent b42be2b391
commit b8032e7fbf
3 changed files with 10 additions and 11 deletions

View File

@ -1090,6 +1090,8 @@ namespace i2p
UpdateSSU2Keys (); UpdateSSU2Keys ();
updated = true; updated = true;
} }
if (m_RouterInfo.UpdateCongestion (i2p::data::RouterInfo::eLowCongestion))
updated = true;
if (updated) if (updated)
UpdateRouterInfo (); UpdateRouterInfo ();
@ -1398,7 +1400,12 @@ namespace i2p
{ {
if (ecode != boost::asio::error::operation_aborted) if (ecode != boost::asio::error::operation_aborted)
{ {
if (m_RouterInfo.SetHighCongestion (IsHighCongestion ())) auto c = i2p::data::RouterInfo::eLowCongestion;
if (!AcceptsTunnels ())
c = i2p::data::RouterInfo::eRejectAll;
else if (IsHighCongestion ())
c = i2p::data::RouterInfo::eHighCongestion;
if (m_RouterInfo.UpdateCongestion (c))
UpdateRouterInfo (); UpdateRouterInfo ();
ScheduleCongestionUpdate (); ScheduleCongestionUpdate ();
} }

View File

@ -1077,12 +1077,6 @@ namespace data
if (m_Congestion == eHighCongestion) if (m_Congestion == eHighCongestion)
return (i2p::util::GetMillisecondsSinceEpoch () < m_Timestamp + HIGH_CONGESTION_INTERVAL*1000LL) ? true : false; return (i2p::util::GetMillisecondsSinceEpoch () < m_Timestamp + HIGH_CONGESTION_INTERVAL*1000LL) ? true : false;
return false; return false;
}
LocalRouterInfo::LocalRouterInfo (const std::string& fullPath):
RouterInfo (fullPath)
{
SetHighCongestion (false); // drop congestion
} }
void LocalRouterInfo::CreateBuffer (const PrivateKeys& privateKeys) void LocalRouterInfo::CreateBuffer (const PrivateKeys& privateKeys)
@ -1153,9 +1147,8 @@ namespace data
SetProperty ("caps", caps); SetProperty ("caps", caps);
} }
bool LocalRouterInfo::SetHighCongestion (bool highCongestion) bool LocalRouterInfo::UpdateCongestion (Congestion c)
{ {
Congestion c = highCongestion ? eHighCongestion : eLowCongestion;
if (c != GetCongestion ()) if (c != GetCongestion ())
{ {
SetCongestion (c); SetCongestion (c);

View File

@ -330,10 +330,9 @@ namespace data
public: public:
LocalRouterInfo () = default; LocalRouterInfo () = default;
LocalRouterInfo (const std::string& fullPath);
void CreateBuffer (const PrivateKeys& privateKeys); void CreateBuffer (const PrivateKeys& privateKeys);
void UpdateCaps (uint8_t caps); void UpdateCaps (uint8_t caps);
bool SetHighCongestion (bool highCongestion); // returns true if updated bool UpdateCongestion (Congestion c); // returns true if updated
void SetProperty (const std::string& key, const std::string& value) override; void SetProperty (const std::string& key, const std::string& value) override;
void DeleteProperty (const std::string& key); void DeleteProperty (const std::string& key);