Browse Source

Merge pull request #1925 from wekoq/openssl

Do not save useless peer profiles
pull/1927/head
orignal 2 years ago committed by GitHub
parent
commit
f2bc2598dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      libi2pd/Profiling.cpp
  2. 3
      libi2pd/Profiling.h

13
libi2pd/Profiling.cpp

@ -160,8 +160,10 @@ namespace data @@ -160,8 +160,10 @@ namespace data
m_NumTunnelsNonReplied++;
UpdateTime ();
if (m_NumTunnelsNonReplied > 2*m_NumTunnelsAgreed && m_NumTunnelsNonReplied > 3)
{
m_LastDeclineTime = i2p::util::GetSecondsSinceEpoch ();
}
}
void RouterProfile::Unreachable ()
{
@ -222,6 +224,15 @@ namespace data @@ -222,6 +224,15 @@ namespace data
return (bool)m_LastUnreachableTime;
}
bool RouterProfile::IsUseful() const {
return
m_NumTunnelsAgreed >= PEER_PROFILE_USEFUL_THRESHOLD ||
m_NumTunnelsDeclined >= PEER_PROFILE_USEFUL_THRESHOLD ||
m_NumTunnelsNonReplied >= PEER_PROFILE_USEFUL_THRESHOLD ||
m_HasConnected;
}
std::shared_ptr<RouterProfile> GetRouterProfile (const IdentHash& identHash)
{
{
@ -275,7 +286,7 @@ namespace data @@ -275,7 +286,7 @@ namespace data
}
auto ts = GetTime ();
for (auto& it: tmp)
if (it.second->IsUpdated () && (ts - it.second->GetLastUpdateTime ()).total_seconds () < PEER_PROFILE_EXPIRATION_TIMEOUT*3600)
if (it.second->IsUseful() && it.second->IsUpdated () && (ts - it.second->GetLastUpdateTime ()).total_seconds () < PEER_PROFILE_EXPIRATION_TIMEOUT*3600)
it.second->Save (it.first);
}

3
libi2pd/Profiling.h

@ -36,6 +36,7 @@ namespace data @@ -36,6 +36,7 @@ namespace data
const int PEER_PROFILE_DECLINED_RECENTLY_INTERVAL = 150; // in seconds (2.5 minutes)
const int PEER_PROFILE_PERSIST_INTERVAL = 3300; // in seconds (55 minutes)
const int PEER_PROFILE_UNREACHABLE_INTERVAL = 2*3600; // on seconds (2 hours)
const int PEER_PROFILE_USEFUL_THRESHOLD = 3;
class RouterProfile
{
@ -60,6 +61,8 @@ namespace data @@ -60,6 +61,8 @@ namespace data
boost::posix_time::ptime GetLastUpdateTime () const { return m_LastUpdateTime; };
bool IsUpdated () const { return m_IsUpdated; };
bool IsUseful() const;
private:
void UpdateTime ();

Loading…
Cancel
Save