Merge pull request #1175 from majestrate/limit-snode-session-build-rate-2020-03-09

limit path builds on snode sessions
pull/1168/head
Jeff 4 years ago committed by GitHub
commit ac80357552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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
@ -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);

Loading…
Cancel
Save