create new constexpr for the staleness window for introsets and use it in publishing introsets and intro selection

pull/1801/head
Jeff Becker 3 years ago
parent 189c4bfba4
commit 172c2dec45
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -24,6 +24,9 @@ namespace llarp
constexpr auto intro_spread_slices = 4;
/// spacing frequency at which we try to build paths for introductions
constexpr std::chrono::milliseconds intro_path_spread = default_lifetime / intro_spread_slices;
/// how long away from expiration in millseconds do we consider an intro to become stale
constexpr std::chrono::milliseconds intro_stale_threshold =
default_lifetime - intro_path_spread;
/// Minimum paths to keep around for intros; mainly used at startup (the
/// spread, above, should be able to maintain more than this number of paths
/// normally once things are going).

@ -104,7 +104,7 @@ namespace llarp
std::set<Introduction, CompareIntroTimestamp> intros;
if (const auto maybe =
GetCurrentIntroductionsWithFilter([now](const service::Introduction& intro) -> bool {
return not intro.ExpiresSoon(now, path::default_lifetime - path::intro_path_spread);
return not intro.ExpiresSoon(now, path::intro_stale_threshold);
}))
{
intros.insert(maybe->begin(), maybe->end());
@ -735,8 +735,7 @@ namespace llarp
const auto lastEventAt = std::max(m_state->m_LastPublishAttempt, m_state->m_LastPublish);
const auto next_pub = lastEventAt
+ (m_state->m_IntroSet.HasStaleIntros(
now, path::default_lifetime - path::intro_path_spread)
+ (m_state->m_IntroSet.HasStaleIntros(now, path::intro_stale_threshold)
? IntrosetPublishRetryCooldown
: IntrosetPublishInterval);

Loading…
Cancel
Save