Don't republish when we have extra paths

This caused some unwanted behaviour:

- on initial startup we often get two publishes in quick succession
because we're publishing and building paths at the same time

- at the 10m mark we enter a publish loop every 5 seconds because we
have paths with lifetimes < 10min that was triggering this condition,
and yet those paths will never actually be included in the introset
because they are expiring in <10m.
pull/1147/head
Jason Rhinelander 4 years ago
parent c0eb0c4db4
commit cfee824a79

@ -571,26 +571,13 @@ namespace llarp
{
if(not m_PublishIntroSet)
return false;
// make sure we have all paths that are established
// in our introset
size_t numNotInIntroset = 0;
ForEachPath([&](const path::Path_ptr& p) {
if(!p->IsReady())
return;
for(const auto& introset : introSet().I)
{
if(introset == p->intro)
return;
}
++numNotInIntroset;
});
const auto lastpub = m_state->m_LastPublishAttempt;
if(m_state->m_IntroSet.HasExpiredIntros(now) || numNotInIntroset > 1)
{
return now - lastpub >= INTROSET_PUBLISH_RETRY_INTERVAL;
}
return now - lastpub >= INTROSET_PUBLISH_INTERVAL;
auto next_pub = m_state->m_LastPublishAttempt
+ (m_state->m_IntroSet.HasExpiredIntros(now)
? INTROSET_PUBLISH_RETRY_INTERVAL
: INTROSET_PUBLISH_INTERVAL);
return now >= next_pub;
}
void

Loading…
Cancel
Save