mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
select first hop from existing connections if applicable
This commit is contained in:
parent
7f172964f6
commit
d2b4a6fd50
3 changed files with 23 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue