Skip to content

Commit

Permalink
Merge pull request #1175 from majestrate/limit-snode-session-build-ra…
Browse files Browse the repository at this point in the history
…te-2020-03-09

limit path builds on snode sessions
  • Loading branch information
majestrate authored Mar 11, 2020
2 parents 3f4b2a5 + 677e19e commit ac80357
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion llarp/exit/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ namespace llarp
bool
BaseSession::ShouldBuildMore(llarp_time_t now) const
{
if(BuildCooldownHit(now))
return false;
const size_t expect = (1 + (numPaths / 2));
// check 30 seconds into the future and see if we need more paths
const llarp_time_t future = now + 30s + buildIntervalLimit;
return NumPathsExistingAt(future) < expect && !BuildCooldownHit(now);
return NumPathsExistingAt(future) < expect;
}

void
Expand Down Expand Up @@ -259,6 +261,8 @@ namespace llarp
bool
BaseSession::UrgentBuild(llarp_time_t now) const
{
if(BuildCooldownHit(now))
return false;
if(!IsReady())
return NumInStatus(path::ePathBuilding) < numPaths;
return path::Builder::UrgentBuild(now);
Expand Down

0 comments on commit ac80357

Please sign in to comment.