Browse Source

build new tunnels instead slow

pull/1660/head
orignal 3 years ago
parent
commit
5ce9c0f1e2
  1. 3
      libi2pd/Tunnel.h
  2. 4
      libi2pd/TunnelPool.cpp

3
libi2pd/Tunnel.h

@ -38,6 +38,7 @@ namespace tunnel
const int TUNNEL_CREATION_TIMEOUT = 30; // 30 seconds const int TUNNEL_CREATION_TIMEOUT = 30; // 30 seconds
const int STANDARD_NUM_RECORDS = 4; // in VariableTunnelBuild message const int STANDARD_NUM_RECORDS = 4; // in VariableTunnelBuild message
const int MAX_NUM_RECORDS = 8; const int MAX_NUM_RECORDS = 8;
const int HIGH_LATENCY_PER_HOP = 250; // in milliseconds
enum TunnelState enum TunnelState
{ {
@ -98,6 +99,8 @@ namespace tunnel
bool LatencyFitsRange(uint64_t lowerbound, uint64_t upperbound) const; bool LatencyFitsRange(uint64_t lowerbound, uint64_t upperbound) const;
bool LatencyIsKnown() const { return m_Latency > 0; } bool LatencyIsKnown() const { return m_Latency > 0; }
bool IsSlow () const { return LatencyIsKnown() && (int)m_Latency > HIGH_LATENCY_PER_HOP*GetNumHops (); }
protected: protected:
void PrintHops (std::stringstream& s) const; void PrintHops (std::stringstream& s) const;

4
libi2pd/TunnelPool.cpp

@ -525,7 +525,7 @@ namespace tunnel
void TunnelPool::RecreateInboundTunnel (std::shared_ptr<InboundTunnel> tunnel) void TunnelPool::RecreateInboundTunnel (std::shared_ptr<InboundTunnel> tunnel)
{ {
if (IsExploratory ()) // always create new exploratory tunnel if (IsExploratory () || tunnel->IsSlow ()) // always create new exploratory tunnel or if slow
{ {
CreateInboundTunnel (); CreateInboundTunnel ();
return; return;
@ -576,7 +576,7 @@ namespace tunnel
void TunnelPool::RecreateOutboundTunnel (std::shared_ptr<OutboundTunnel> tunnel) void TunnelPool::RecreateOutboundTunnel (std::shared_ptr<OutboundTunnel> tunnel)
{ {
if (IsExploratory ()) // always create new exploratory tunnel if (IsExploratory () || tunnel->IsSlow ()) // always create new exploratory tunnel or if slow
{ {
CreateOutboundTunnel (); CreateOutboundTunnel ();
return; return;

Loading…
Cancel
Save