|
|
@ -107,7 +107,10 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::util::SetThreadName("NetDB"); |
|
|
|
i2p::util::SetThreadName("NetDB"); |
|
|
|
|
|
|
|
|
|
|
|
uint32_t lastSave = 0, lastPublish = 0, lastExploratory = 0, lastManageRequest = 0, lastDestinationCleanup = 0; |
|
|
|
uint64_t lastSave = 0, lastPublish = 0, lastExploratory = 0, lastManageRequest = 0, lastDestinationCleanup = 0; |
|
|
|
|
|
|
|
uint64_t lastProfilesCleanup = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
|
|
|
|
uint64_t profilesCleanupVariance = (rand () % (2 * i2p::data::PEER_PROFILE_AUTOCLEAN_VARIANCE) - i2p::data::PEER_PROFILE_AUTOCLEAN_VARIANCE); |
|
|
|
|
|
|
|
|
|
|
|
while (m_IsRunning) |
|
|
|
while (m_IsRunning) |
|
|
|
{ |
|
|
|
{ |
|
|
|
try |
|
|
|
try |
|
|
@ -155,6 +158,7 @@ namespace data |
|
|
|
m_Requests.ManageRequests (); |
|
|
|
m_Requests.ManageRequests (); |
|
|
|
lastManageRequest = ts; |
|
|
|
lastManageRequest = ts; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (ts - lastSave >= 60) // save routers, manage leasesets and validate subscriptions every minute
|
|
|
|
if (ts - lastSave >= 60) // save routers, manage leasesets and validate subscriptions every minute
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (lastSave) |
|
|
|
if (lastSave) |
|
|
@ -164,12 +168,19 @@ namespace data |
|
|
|
} |
|
|
|
} |
|
|
|
lastSave = ts; |
|
|
|
lastSave = ts; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (ts - lastDestinationCleanup >= i2p::garlic::INCOMING_TAGS_EXPIRATION_TIMEOUT) |
|
|
|
if (ts - lastDestinationCleanup >= i2p::garlic::INCOMING_TAGS_EXPIRATION_TIMEOUT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::context.CleanupDestination (); |
|
|
|
i2p::context.CleanupDestination (); |
|
|
|
lastDestinationCleanup = ts; |
|
|
|
lastDestinationCleanup = ts; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ts - lastProfilesCleanup >= (i2p::data::PEER_PROFILE_AUTOCLEAN_TIMEOUT + profilesCleanupVariance)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DeleteObsoleteProfiles (); |
|
|
|
|
|
|
|
lastProfilesCleanup = ts; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// publish
|
|
|
|
// publish
|
|
|
|
if (!m_HiddenMode && i2p::transport::transports.IsOnline ()) |
|
|
|
if (!m_HiddenMode && i2p::transport::transports.IsOnline ()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -195,6 +206,7 @@ namespace data |
|
|
|
lastPublish = ts; |
|
|
|
lastPublish = ts; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (ts - lastExploratory >= 30) // exploratory every 30 seconds
|
|
|
|
if (ts - lastExploratory >= 30) // exploratory every 30 seconds
|
|
|
|
{ |
|
|
|
{ |
|
|
|
auto numRouters = m_RouterInfos.size (); |
|
|
|
auto numRouters = m_RouterInfos.size (); |
|
|
|