|
|
@ -109,7 +109,7 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
void NetDb::Run () |
|
|
|
void NetDb::Run () |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t lastSave = 0, lastPublish = 0; |
|
|
|
uint32_t lastSave = 0, lastPublish = 0, lastExploratory = 0; |
|
|
|
m_IsRunning = true; |
|
|
|
m_IsRunning = true; |
|
|
|
while (m_IsRunning) |
|
|
|
while (m_IsRunning) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -144,10 +144,7 @@ namespace data |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_IsRunning) break; |
|
|
|
if (!m_IsRunning) break; |
|
|
|
// if no new DatabaseStore coming, explore it
|
|
|
|
|
|
|
|
ManageRequests (); |
|
|
|
ManageRequests (); |
|
|
|
auto numRouters = m_RouterInfos.size (); |
|
|
|
|
|
|
|
Explore (numRouters < 1500 ? 5 : 1); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
uint64_t ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
@ -165,6 +162,18 @@ namespace data |
|
|
|
Publish (); |
|
|
|
Publish (); |
|
|
|
lastPublish = ts; |
|
|
|
lastPublish = ts; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (ts - lastExploratory >= 30) // exploratory every 30 seconds
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto numRouters = m_RouterInfos.size (); |
|
|
|
|
|
|
|
if (numRouters < 2500 || ts - lastExploratory >= 90) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
numRouters = 800/numRouters; |
|
|
|
|
|
|
|
if (numRouters < 1) numRouters = 1; |
|
|
|
|
|
|
|
if (numRouters > 9) numRouters = 9; |
|
|
|
|
|
|
|
Explore (numRouters); |
|
|
|
|
|
|
|
lastExploratory = ts; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (std::exception& ex) |
|
|
|
catch (std::exception& ex) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -641,8 +650,8 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
// new requests
|
|
|
|
// new requests
|
|
|
|
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool (); |
|
|
|
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool (); |
|
|
|
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : i2p::tunnel::tunnels.GetNextOutboundTunnel (); |
|
|
|
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr; |
|
|
|
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : i2p::tunnel::tunnels.GetNextInboundTunnel (); |
|
|
|
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr; |
|
|
|
bool throughTunnels = outbound && inbound; |
|
|
|
bool throughTunnels = outbound && inbound; |
|
|
|
|
|
|
|
|
|
|
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); |
|
|
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); |
|
|
|