select first hop from existing connections if applicable

This commit is contained in:
orignal 2015-05-05 10:33:19 -04:00
parent 7f172964f6
commit d2b4a6fd50
3 changed files with 23 additions and 2 deletions

View file

@ -489,6 +489,14 @@ namespace transport
m_PeerCleanupTimer.async_wait (std::bind (&Transports::HandlePeerCleanupTimer, this, std::placeholders::_1));
}
}
std::shared_ptr<const i2p::data::RouterInfo> Transports::GetRandomPeer () const
{
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
auto it = m_Peers.begin ();
std::advance (it, rnd.GenerateWord32 (0, m_Peers.size () - 1));
return it != m_Peers.end () ? it->second.router : nullptr;
}
}
}