build new tunnels instead slow

This commit is contained in:
orignal 2021-06-02 14:45:21 -04:00
parent ef8c4389e1
commit 5ce9c0f1e2
2 changed files with 5 additions and 2 deletions

View File

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

View File

@ -525,7 +525,7 @@ namespace 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 ();
return;
@ -576,7 +576,7 @@ namespace 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 ();
return;