more clairvoient path building

pull/576/head
Jeff Becker 6 years ago
parent 36369abcb4
commit 33d1fb913f
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -49,14 +49,12 @@ namespace llarp
bool bool
BaseSession::ShouldBuildMore(llarp_time_t now) const BaseSession::ShouldBuildMore(llarp_time_t now) const
{ {
if(!path::Builder::ShouldBuildMore(now))
return false;
const size_t expect = (1 + (m_NumPaths / 2)); const size_t expect = (1 + (m_NumPaths / 2));
// check 30 seconds into the future and see if we need more paths // check 30 seconds into the future and see if we need more paths
const llarp_time_t future = now + (30 * 1000); const llarp_time_t future = now + (30 * 1000);
if(NumPathsExistingAt(future) < expect) return NumPathsExistingAt(future) < expect;
return llarp::randint() % 4
== 0; // 25% chance for build if we will run out soon
// maintain regular number of paths
return path::Builder::ShouldBuildMore(now);
} }
bool bool

Loading…
Cancel
Save