better exit path logic

pull/90/head
Jeff 6 years ago
parent 736b313c4c
commit a33f334bc2

@ -60,6 +60,10 @@ namespace llarp
void
Tick(llarp_time_t now, llarp_router* r);
/// count the number of paths that will exist at this timestamp in future
size_t
NumPathsExistingAt(llarp_time_t futureTime) const;
void
RemovePath(Path* path);

@ -22,8 +22,12 @@ namespace llarp
bool
BaseSession::ShouldBuildMore(llarp_time_t now) const
{
return AvailablePaths(llarp::path::ePathRoleExit) == 0
|| path::Builder::ShouldBuildMore(now);
const size_t expect = (1 + (m_NumPaths / 2));
if(NumPathsExistingAt(now + (10 * 1000)) < expect)
return true;
if(AvailablePaths(llarp::path::ePathRoleExit) < expect)
return true;
return false;
}
bool

@ -335,7 +335,7 @@ namespace llarp
TunEndpoint::Tick(llarp_time_t now)
{
// call tun code in endpoint logic in case of network isolation
llarp_logic_queue_job(EndpointLogic(), {this, handleTickTun});
//llarp_logic_queue_job(EndpointLogic(), {this, handleTickTun});
FlushSend();
Endpoint::Tick(now);
}

@ -41,6 +41,18 @@ namespace llarp
return 0;
}
size_t
PathSet::NumPathsExistingAt(llarp_time_t futureTime) const
{
size_t num = 0;
for(const auto & item : m_Paths)
{
if(!item.second->Expired(futureTime))
++num;
}
return num;
}
void
PathSet::Tick(llarp_time_t now, llarp_router* r)
{

@ -131,10 +131,6 @@ namespace llarp
{
RegenAndPublishIntroSet(now);
}
if(m_Exit)
{
m_Exit->Tick(now, m_Router);
}
// expire pending tx
{
std::set< service::IntroSet > empty;

Loading…
Cancel
Save