mirror of https://github.com/oxen-io/lokinet
Merge pull request #1801 from majestrate/introset-publish-spam-fix-2021-11-16
prevent introset publish spam
This commit is contained in:
commit
9e4bd2cd44
|
@ -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,8 +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::min_intro_lifetime);
|
||||
return not intro.ExpiresSoon(now, path::intro_stale_threshold);
|
||||
}))
|
||||
{
|
||||
intros.insert(maybe->begin(), maybe->end());
|
||||
|
@ -734,13 +733,13 @@ namespace llarp
|
|||
if (not m_PublishIntroSet)
|
||||
return false;
|
||||
|
||||
auto next_pub = m_state->m_LastPublishAttempt
|
||||
+ (m_state->m_IntroSet.HasStaleIntros(
|
||||
now, path::default_lifetime - path::intro_path_spread)
|
||||
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::intro_stale_threshold)
|
||||
? IntrosetPublishRetryCooldown
|
||||
: IntrosetPublishInterval);
|
||||
|
||||
return now >= next_pub and m_LastIntrosetRegenAttempt + 1s <= now;
|
||||
return now >= next_pub;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue