Skip to content

Commit

Permalink
handle siuatuion if only one lease in remote LeaseSet
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Sep 18, 2024
1 parent 13b2fc3 commit ca4db7a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libi2pd/Streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,16 +1460,19 @@ namespace stream
break;
}
}
if (!updated && leases.size () > 1)
if (!updated)
{
uint32_t i = m_LocalDestination.GetRandom () % leases.size ();
if (m_CurrentRemoteLease && leases[i]->tunnelID == m_CurrentRemoteLease->tunnelID)
{
// make sure we don't select previous
i = (i + 1) % leases.size (); // if so, pick next
if (leases.size () > 1)
i = (i + 1) % leases.size (); // if so, pick next
else
isLeaseChanged = false;
}
m_CurrentRemoteLease = leases[i];
}
else
isLeaseChanged = false;
}
else
{
Expand Down

0 comments on commit ca4db7a

Please sign in to comment.