Browse Source

count non-replied tunnel build requests

pull/170/head
orignal 10 years ago
parent
commit
1a440e3a83
  1. 10
      Profiling.cpp
  2. 5
      Profiling.h
  3. 13
      Tunnel.cpp

10
Profiling.cpp

@ -10,7 +10,8 @@ namespace i2p @@ -10,7 +10,8 @@ namespace i2p
namespace data
{
RouterProfile::RouterProfile (const IdentHash& identHash):
m_IdentHash (identHash), m_NumTunnelsAgreed (0), m_NumTunnelsDeclined (0)
m_IdentHash (identHash), m_NumTunnelsAgreed (0), m_NumTunnelsDeclined (0),
m_NumTunnelsNonReplied (0)
{
}
@ -20,6 +21,7 @@ namespace data @@ -20,6 +21,7 @@ namespace data
boost::property_tree::ptree participation;
participation.put (PEER_PROFILE_PARTICIPATION_AGREED, m_NumTunnelsAgreed);
participation.put (PEER_PROFILE_PARTICIPATION_DECLINED, m_NumTunnelsDeclined);
participation.put (PEER_PROFILE_PARTICIPATION_NON_REPLIED, m_NumTunnelsNonReplied);
// fill property tree
boost::property_tree::ptree pt;
pt.put_child (PEER_PROFILE_SECTION_PARTICIPATION, participation);
@ -82,6 +84,7 @@ namespace data @@ -82,6 +84,7 @@ namespace data
auto participations = pt.get_child (PEER_PROFILE_SECTION_PARTICIPATION);
m_NumTunnelsAgreed = participations.get (PEER_PROFILE_PARTICIPATION_AGREED, 0);
m_NumTunnelsDeclined = participations.get (PEER_PROFILE_PARTICIPATION_DECLINED, 0);
m_NumTunnelsNonReplied = participations.get (PEER_PROFILE_PARTICIPATION_NON_REPLIED, 0);
}
catch (std::exception& ex)
{
@ -97,6 +100,11 @@ namespace data @@ -97,6 +100,11 @@ namespace data
else
m_NumTunnelsAgreed++;
}
void RouterProfile::TunnelNonReplied ()
{
m_NumTunnelsNonReplied++;
}
std::shared_ptr<RouterProfile> GetRouterProfile (const IdentHash& identHash)
{

5
Profiling.h

@ -15,6 +15,7 @@ namespace data @@ -15,6 +15,7 @@ namespace data
// params
const char PEER_PROFILE_PARTICIPATION_AGREED[] = "agreed";
const char PEER_PROFILE_PARTICIPATION_DECLINED[] = "declined";
const char PEER_PROFILE_PARTICIPATION_NON_REPLIED[] = "nonreplied";
class RouterProfile
{
@ -28,13 +29,15 @@ namespace data @@ -28,13 +29,15 @@ namespace data
bool IsBad () const { return !m_NumTunnelsAgreed && m_NumTunnelsDeclined >= 5; };
void TunnelBuildResponse (uint8_t ret);
void TunnelNonReplied ();
private:
IdentHash m_IdentHash;
// participation
uint32_t m_NumTunnelsAgreed;
uint32_t m_NumTunnelsDeclined;
uint32_t m_NumTunnelsDeclined;
uint32_t m_NumTunnelsNonReplied;
};
std::shared_ptr<RouterProfile> GetRouterProfile (const IdentHash& identHash);

13
Tunnel.cpp

@ -489,6 +489,19 @@ namespace tunnel @@ -489,6 +489,19 @@ namespace tunnel
if (ts > tunnel->GetCreationTime () + TUNNEL_CREATION_TIMEOUT)
{
LogPrint ("Pending tunnel build request ", it->first, " timeout. Deleted");
// update stats
auto config = tunnel->GetTunnelConfig ();
if (config)
{
auto hop = config->GetFirstHop ();
while (hop)
{
if (hop->router)
hop->router->GetProfile ()->TunnelNonReplied ();
hop = hop->next;
}
}
// delete
it = pendingTunnels.erase (it);
m_NumFailedTunnelCreations++;
}

Loading…
Cancel
Save