mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
consistent path for explicit peers
This commit is contained in:
parent
9a3c22f47d
commit
f8623b6121
@ -505,15 +505,12 @@ namespace tunnel
|
|||||||
|
|
||||||
bool TunnelPool::SelectExplicitPeers (Path& path, bool isInbound)
|
bool TunnelPool::SelectExplicitPeers (Path& path, bool isInbound)
|
||||||
{
|
{
|
||||||
int size = m_ExplicitPeers->size ();
|
|
||||||
std::vector<int> peerIndicies;
|
|
||||||
for (int i = 0; i < size; i++) peerIndicies.push_back(i);
|
|
||||||
std::shuffle (peerIndicies.begin(), peerIndicies.end(), std::mt19937(std::random_device()()));
|
|
||||||
|
|
||||||
int numHops = isInbound ? m_NumInboundHops : m_NumOutboundHops;
|
int numHops = isInbound ? m_NumInboundHops : m_NumOutboundHops;
|
||||||
|
if (numHops > (int)m_ExplicitPeers->size ()) numHops = m_ExplicitPeers->size ();
|
||||||
|
if (!numHops) return false;
|
||||||
for (int i = 0; i < numHops; i++)
|
for (int i = 0; i < numHops; i++)
|
||||||
{
|
{
|
||||||
auto& ident = (*m_ExplicitPeers)[peerIndicies[i]];
|
auto& ident = (*m_ExplicitPeers)[i];
|
||||||
auto r = i2p::data::netdb.FindRouter (ident);
|
auto r = i2p::data::netdb.FindRouter (ident);
|
||||||
if (r)
|
if (r)
|
||||||
path.Add (r);
|
path.Add (r);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user