@ -40,16 +40,10 @@
# include <uvw.hpp>
# include <variant>
namespace
{
constexpr size_t MIN_ENDPOINTS_FOR_LNS_LOOKUP = 2 ;
} // namespace
namespace llarp
{
namespace service
{
static auto logcat = log : : Cat ( " endpoint " ) ;
Endpoint : : Endpoint ( AbstractRouter * r , Context * parent )
@ -317,7 +311,7 @@ namespace llarp
auto obj = path : : Builder : : ExtractStatus ( ) ;
obj [ " exitMap " ] = m_ExitMap . ExtractStatus ( ) ;
obj [ " identity " ] = m_Identity . pub . Addr ( ) . ToString ( ) ;
obj [ " networkReady " ] = Ready ToDoLookup ( ) ;
obj [ " networkReady " ] = Ready ForNetwork ( ) ;
util : : StatusObject authCodes ;
for ( const auto & [ service , info ] : m_RemoteAuthInfos )
@ -958,20 +952,28 @@ namespace llarp
return not m_ExitMap . Empty ( ) ;
}
path : : Path : : UniqueEndpointSet_t
Endpoint : : GetUniqueEndpointsForLookup ( ) const
{
path : : Path : : UniqueEndpointSet_t paths ;
ForEachPath ( [ & paths ] ( auto path ) {
if ( path and path - > IsReady ( ) )
paths . insert ( path ) ;
} ) ;
return paths ;
}
bool
Endpoint : : ReadyToDoLookup ( std : : optional < uint64_t > numPaths ) const
Endpoint : : Ready ForNetwork( ) const
{
if ( not numPaths )
{
path : : Path : : UniqueEndpointSet_t paths ;
ForEachPath ( [ & paths ] ( auto path ) {
if ( path and path - > IsReady ( ) )
paths . insert ( path ) ;
} ) ;
numPaths = paths . size ( ) ;
}
return IsReady ( ) and ReadyToDoLookup ( GetUniqueEndpointsForLookup ( ) . size ( ) ) ;
}
return numPaths > = MIN_ENDPOINTS_FOR_LNS_LOOKUP ;
bool
Endpoint : : ReadyToDoLookup ( size_t num_paths ) const
{
// Currently just checks the number of paths, but could do more checks in the future. (jason)
return num_paths > = MIN_ENDPOINTS_FOR_LNS_LOOKUP ;
}
void
@ -992,12 +994,7 @@ namespace llarp
return ;
}
LogInfo ( Name ( ) , " looking up LNS name: " , name ) ;
path : : Path : : UniqueEndpointSet_t paths ;
ForEachPath ( [ & paths ] ( auto path ) {
if ( path and path - > IsReady ( ) )
paths . insert ( path ) ;
} ) ;
auto paths = GetUniqueEndpointsForLookup ( ) ;
// not enough paths
if ( not ReadyToDoLookup ( paths . size ( ) ) )
{