mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
don't pick node for 5 minutes if declined
This commit is contained in:
parent
a96482b186
commit
d9c0f52846
2 changed files with 10 additions and 4 deletions
|
@ -11,6 +11,7 @@ namespace data
|
||||||
{
|
{
|
||||||
RouterProfile::RouterProfile (const IdentHash& identHash):
|
RouterProfile::RouterProfile (const IdentHash& identHash):
|
||||||
m_IdentHash (identHash), m_LastUpdateTime (boost::posix_time::second_clock::local_time()),
|
m_IdentHash (identHash), m_LastUpdateTime (boost::posix_time::second_clock::local_time()),
|
||||||
|
m_LastDeclinedTime (boost::posix_time::min_date_time),
|
||||||
m_NumTunnelsAgreed (0), m_NumTunnelsDeclined (0), m_NumTunnelsNonReplied (0),
|
m_NumTunnelsAgreed (0), m_NumTunnelsDeclined (0), m_NumTunnelsNonReplied (0),
|
||||||
m_NumTimesTaken (0), m_NumTimesRejected (0)
|
m_NumTimesTaken (0), m_NumTimesRejected (0)
|
||||||
{
|
{
|
||||||
|
@ -137,11 +138,14 @@ namespace data
|
||||||
|
|
||||||
void RouterProfile::TunnelBuildResponse (uint8_t ret)
|
void RouterProfile::TunnelBuildResponse (uint8_t ret)
|
||||||
{
|
{
|
||||||
|
UpdateTime ();
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
m_LastDeclinedTime = m_LastUpdateTime;
|
||||||
m_NumTunnelsDeclined++;
|
m_NumTunnelsDeclined++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
m_NumTunnelsAgreed++;
|
m_NumTunnelsAgreed++;
|
||||||
UpdateTime ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterProfile::TunnelNonReplied ()
|
void RouterProfile::TunnelNonReplied ()
|
||||||
|
@ -163,7 +167,8 @@ namespace data
|
||||||
|
|
||||||
bool RouterProfile::IsBad ()
|
bool RouterProfile::IsBad ()
|
||||||
{
|
{
|
||||||
auto elapsedTime = (GetTime () - m_LastUpdateTime).total_seconds ();
|
auto t = GetTime ();
|
||||||
|
auto elapsedTime = (t - m_LastUpdateTime).total_seconds ();
|
||||||
if (elapsedTime > 1800)
|
if (elapsedTime > 1800)
|
||||||
{
|
{
|
||||||
m_NumTunnelsNonReplied = 0; // drop non-replied after 30 minutes of inactivity
|
m_NumTunnelsNonReplied = 0; // drop non-replied after 30 minutes of inactivity
|
||||||
|
@ -173,7 +178,8 @@ namespace data
|
||||||
m_NumTunnelsDeclined = 0;
|
m_NumTunnelsDeclined = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto isBad = IsAlwaysDeclining () || IsLowPartcipationRate () || IsLowReplyRate ();
|
auto isBad = IsAlwaysDeclining () || IsLowPartcipationRate () || IsLowReplyRate () ||
|
||||||
|
((t - m_LastDeclinedTime).total_seconds () < 300); // declined in last 5 minutes
|
||||||
if (isBad) m_NumTimesRejected++; else m_NumTimesTaken++;
|
if (isBad) m_NumTimesRejected++; else m_NumTimesTaken++;
|
||||||
return isBad;
|
return isBad;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace data
|
||||||
private:
|
private:
|
||||||
|
|
||||||
IdentHash m_IdentHash;
|
IdentHash m_IdentHash;
|
||||||
boost::posix_time::ptime m_LastUpdateTime;
|
boost::posix_time::ptime m_LastUpdateTime, m_LastDeclinedTime;
|
||||||
// participation
|
// participation
|
||||||
uint32_t m_NumTunnelsAgreed;
|
uint32_t m_NumTunnelsAgreed;
|
||||||
uint32_t m_NumTunnelsDeclined;
|
uint32_t m_NumTunnelsDeclined;
|
||||||
|
|
Loading…
Add table
Reference in a new issue