mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-13 04:46:38 +01:00
pick tunnels from exploratory pool for exploratory
This commit is contained in:
parent
13b2036e52
commit
24f0ff6c00
4 changed files with 23 additions and 3 deletions
|
@ -532,8 +532,9 @@ namespace data
|
||||||
|
|
||||||
void NetDb::Explore ()
|
void NetDb::Explore ()
|
||||||
{
|
{
|
||||||
auto outbound = i2p::tunnel::tunnels.GetNextOutboundTunnel ();
|
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool ();
|
||||||
auto inbound = i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr;
|
||||||
|
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr;
|
||||||
if (outbound && inbound)
|
if (outbound && inbound)
|
||||||
{
|
{
|
||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
|
|
1
Tunnel.h
1
Tunnel.h
|
@ -117,6 +117,7 @@ namespace tunnel
|
||||||
Tunnel * GetPendingTunnel (uint32_t replyMsgID);
|
Tunnel * GetPendingTunnel (uint32_t replyMsgID);
|
||||||
InboundTunnel * GetNextInboundTunnel ();
|
InboundTunnel * GetNextInboundTunnel ();
|
||||||
OutboundTunnel * GetNextOutboundTunnel ();
|
OutboundTunnel * GetNextOutboundTunnel ();
|
||||||
|
TunnelPool * GetExploratoryPool () const { return m_ExploratoryPool; };
|
||||||
TransitTunnel * GetTransitTunnel (uint32_t tunnelID);
|
TransitTunnel * GetTransitTunnel (uint32_t tunnelID);
|
||||||
void AddTransitTunnel (TransitTunnel * tunnel);
|
void AddTransitTunnel (TransitTunnel * tunnel);
|
||||||
void AddOutboundTunnel (OutboundTunnel * newTunnel);
|
void AddOutboundTunnel (OutboundTunnel * newTunnel);
|
||||||
|
|
|
@ -86,7 +86,22 @@ namespace tunnel
|
||||||
m_LastOutboundTunnel = tunnel;
|
m_LastOutboundTunnel = tunnel;
|
||||||
return tunnel;
|
return tunnel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InboundTunnel * TunnelPool::GetNextInboundTunnel ()
|
||||||
|
{
|
||||||
|
return GetNextTunnel (m_InboundTunnels);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class TTunnels>
|
||||||
|
typename TTunnels::value_type TunnelPool::GetNextTunnel (TTunnels& tunnels)
|
||||||
|
{
|
||||||
|
if (tunnels.empty ()) return nullptr;
|
||||||
|
for (auto it: tunnels)
|
||||||
|
if (!it->IsFailed ())
|
||||||
|
return it;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void TunnelPool::CreateTunnels ()
|
void TunnelPool::CreateTunnels ()
|
||||||
{
|
{
|
||||||
int num = m_InboundTunnels.size ();
|
int num = m_InboundTunnels.size ();
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace tunnel
|
||||||
void TunnelExpired (OutboundTunnel * expiredTunnel);
|
void TunnelExpired (OutboundTunnel * expiredTunnel);
|
||||||
std::vector<InboundTunnel *> GetInboundTunnels (int num) const;
|
std::vector<InboundTunnel *> GetInboundTunnels (int num) const;
|
||||||
OutboundTunnel * GetNextOutboundTunnel ();
|
OutboundTunnel * GetNextOutboundTunnel ();
|
||||||
|
InboundTunnel * GetNextInboundTunnel ();
|
||||||
const i2p::data::IdentHash& GetIdentHash () { return m_LocalDestination.GetIdentHash (); };
|
const i2p::data::IdentHash& GetIdentHash () { return m_LocalDestination.GetIdentHash (); };
|
||||||
|
|
||||||
void TestTunnels ();
|
void TestTunnels ();
|
||||||
|
@ -46,6 +47,8 @@ namespace tunnel
|
||||||
|
|
||||||
void CreateInboundTunnel ();
|
void CreateInboundTunnel ();
|
||||||
void CreateOutboundTunnel ();
|
void CreateOutboundTunnel ();
|
||||||
|
template<class TTunnels>
|
||||||
|
typename TTunnels::value_type GetNextTunnel (TTunnels& tunnels);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue