llarp::path::PathSet

a set of paths owned by an entity

#include <pathset.hpp>

Inherited by llarp::path::Builder

Protected Types

Name
using util::NullMutex Mtx_t
using util::NullLock Lock_t
using std::unordered_map< std::pair< RouterID, PathID_t >, Path_ptr > PathMap_t

Public Functions

Name
PathSet(size_t numDesiredPaths)
construct @params numDesiredPaths the number of paths to maintain
virtual PathSet_ptr GetSelf() =0
get a shared_ptr of ourself
virtual std::weak_ptr< PathSet > GetWeak() =0
get a weak_ptr of ourself
virtual void BuildOne(PathRole roles =ePathRoleAny) =0
virtual void Build(std::vector< RouterContact > hops, PathRole roles =ePathRoleAny) =0
manual build on these hops
virtual void Tick(llarp_time_t now)
tick owned paths
size_t NumPathsExistingAt(llarp_time_t futureTime) const
count the number of paths that will exist at this timestamp in future
virtual void HandlePathBuilt(Path_ptr path) =0
virtual void HandlePathBuildTimeout(Path_ptr path)
virtual void HandlePathBuildFailedAt(Path_ptr path, RouterID hop)
virtual void PathBuildStarted(Path_ptr path)
virtual void HandlePathDied(Path_ptr path)
a path died now what?
bool GetNewestIntro(service::Introduction & intro) const
void AddPath(Path_ptr path)
Path_ptr GetByUpstream(RouterID remote, PathID_t rxid) const
void ExpirePaths(llarp_time_t now, AbstractRouter * router)
size_t NumInStatus(PathStatus st) const
get the number of paths in this status
size_t AvailablePaths(PathRole role) const
get the number of paths that match the role that are available
virtual llarp_time_t Now() const =0
get time from event loop
virtual bool Stop() =0
stop this pathset and mark it as to be removed
virtual bool IsStopped() const =0
return true if we are stopped
virtual std::string Name() const =0
get the "name" of this pathset
virtual bool ShouldRemove() const =0
return true if we can and should remove this pathset and underlying resources from its parent context
virtual bool ShouldBuildMore(llarp_time_t now) const
return true if we should build another path
virtual bool ShouldBuildMoreForRoles(llarp_time_t now, PathRole roles) const
return true if we need another path with the given path roles
virtual size_t MinRequiredForRoles(PathRole roles) const
return the minimum number of paths we want for given roles
virtual bool ShouldPublishDescriptors(llarp_time_t now) const
return true if we should publish a new hidden service descriptor
virtual void BlacklistSNode(const RouterID ) =0
virtual bool HandleGotIntroMessage(std::shared_ptr< const dht::GotIntroMessage > )
override me in subtype
virtual bool HandleGotRouterMessage(std::shared_ptr< const dht::GotRouterMessage > )
override me in subtype
virtual bool HandleGotNameMessage(std::shared_ptr< const dht::GotNameMessage > )
override me in subtype
virtual routing::IMessageHandler * GetDHTHandler()
Path_ptr GetEstablishedPathClosestTo(RouterID router, std::unordered_set< RouterID > excluding ={}, PathRole roles =ePathRoleAny) const
Path_ptr PickEstablishedPath(PathRole roles =ePathRoleAny) const
Path_ptr PickRandomEstablishedPath(PathRole roles =ePathRoleAny) const
Path_ptr GetPathByRouter(RouterID router, PathRole roles =ePathRoleAny) const
Path_ptr GetNewestPathByRouter(RouterID router, PathRole roles =ePathRoleAny) const
Path_ptr GetRandomPathByRouter(RouterID router, PathRole roles =ePathRoleAny) const
Path_ptr GetPathByID(PathID_t id) const
Path_ptr GetByEndpointWithID(RouterID router, PathID_t id) const
std::optional< std::set< service::Introduction > > GetCurrentIntroductionsWithFilter(std::function< bool(const service::Introduction &)> filter) const
virtual bool PublishIntroSet(const service::EncryptedIntroSet & , AbstractRouter * )
virtual void ResetInternalState() =0
reset all cooldown timers
virtual bool BuildOneAlignedTo(const RouterID endpoint) =0
virtual void SendPacketToRemote(const llarp_buffer_t & pkt, service::ProtocolType t) =0
virtual std::optional< std::vector< RouterContact > > GetHopsForBuild() =0
void ForEachPath(std::function< void(const Path_ptr &)> visit) const
void UpstreamFlush(AbstractRouter * r)
void DownstreamFlush(AbstractRouter * r)

Protected Functions

Name
void TickPaths(AbstractRouter * r)

Public Attributes

Name
constexpr size_t max_paths
maximum number of paths a path set can maintain
size_t numDesiredPaths

Protected Attributes

Name
BuildStats m_BuildStats
Mtx_t m_PathsMutex
PathMap_t m_Paths

Protected Types Documentation

using Mtx_t

using llarp::path::PathSet::Mtx_t =  util::NullMutex;

using Lock_t

using llarp::path::PathSet::Lock_t =  util::NullLock;

using PathMap_t

using llarp::path::PathSet::PathMap_t =  std::unordered_map<std::pair<RouterID, PathID_t>, Path_ptr>;

Public Functions Documentation

function PathSet

PathSet(
    size_t numDesiredPaths
)

construct @params numDesiredPaths the number of paths to maintain

function GetSelf

virtual PathSet_ptr GetSelf() =0

get a shared_ptr of ourself

Reimplemented by: llarp::exit::BaseSession::GetSelf, llarp::handlers::NullEndpoint::GetSelf, llarp::handlers::TunEndpoint::GetSelf, llarp::service::OutboundContext::GetSelf

function GetWeak

virtual std::weak_ptr< PathSet > GetWeak() =0

get a weak_ptr of ourself

Reimplemented by: llarp::exit::BaseSession::GetWeak, llarp::handlers::NullEndpoint::GetWeak, llarp::handlers::TunEndpoint::GetWeak, llarp::service::OutboundContext::GetWeak

function BuildOne

virtual void BuildOne(
    PathRole roles =ePathRoleAny
) =0

Reimplemented by: llarp::path::Builder::BuildOne

function Build

virtual void Build(
    std::vector< RouterContact > hops,
    PathRole roles =ePathRoleAny
) =0

manual build on these hops

Reimplemented by: llarp::path::Builder::Build

function Tick

virtual void Tick(
    llarp_time_t now
)

tick owned paths

Reimplemented by: llarp::handlers::TunEndpoint::Tick, llarp::path::Builder::Tick, llarp::service::Endpoint::Tick, llarp::service::OutboundContext::Tick

function NumPathsExistingAt

size_t NumPathsExistingAt(
    llarp_time_t futureTime
) const

count the number of paths that will exist at this timestamp in future

function HandlePathBuilt

virtual void HandlePathBuilt(
    Path_ptr path
) =0

Reimplemented by: llarp::exit::BaseSession::HandlePathBuilt, llarp::service::Endpoint::HandlePathBuilt, llarp::service::OutboundContext::HandlePathBuilt, llarp::path::Builder::HandlePathBuilt

function HandlePathBuildTimeout

virtual void HandlePathBuildTimeout(
    Path_ptr path
)

Reimplemented by: llarp::service::OutboundContext::HandlePathBuildTimeout, llarp::path::Builder::HandlePathBuildTimeout

function HandlePathBuildFailedAt

virtual void HandlePathBuildFailedAt(
    Path_ptr path,
    RouterID hop
)

Reimplemented by: llarp::service::OutboundContext::HandlePathBuildFailedAt, llarp::path::Builder::HandlePathBuildFailedAt

function PathBuildStarted

virtual void PathBuildStarted(
    Path_ptr path
)

Reimplemented by: llarp::service::Endpoint::PathBuildStarted

function HandlePathDied

virtual void HandlePathDied(
    Path_ptr path
)

a path died now what?

Reimplemented by: llarp::exit::BaseSession::HandlePathDied, llarp::service::Endpoint::HandlePathDied, llarp::service::OutboundContext::HandlePathDied

function GetNewestIntro

bool GetNewestIntro(
    service::Introduction & intro
) const

function AddPath

void AddPath(
    Path_ptr path
)

function GetByUpstream

Path_ptr GetByUpstream(
    RouterID remote,
    PathID_t rxid
) const

function ExpirePaths

void ExpirePaths(
    llarp_time_t now,
    AbstractRouter * router
)

function NumInStatus

size_t NumInStatus(
    PathStatus st
) const

get the number of paths in this status

function AvailablePaths

size_t AvailablePaths(
    PathRole role
) const

get the number of paths that match the role that are available

function Now

virtual llarp_time_t Now() const =0

get time from event loop

Reimplemented by: llarp::path::Builder::Now

function Stop

virtual bool Stop() =0

stop this pathset and mark it as to be removed

Reimplemented by: llarp::exit::BaseSession::Stop, llarp::handlers::TunEndpoint::Stop, llarp::path::Builder::Stop, llarp::service::Endpoint::Stop, llarp::service::OutboundContext::Stop

function IsStopped

virtual bool IsStopped() const =0

return true if we are stopped

Reimplemented by: llarp::path::Builder::IsStopped

function Name

virtual std::string Name() const =0

get the "name" of this pathset

Reimplemented by: llarp::exit::ExitSession::Name, llarp::exit::SNodeSession::Name, llarp::service::Endpoint::Name, llarp::service::OutboundContext::Name

function ShouldRemove

virtual bool ShouldRemove() const =0

return true if we can and should remove this pathset and underlying resources from its parent context

Reimplemented by: llarp::path::Builder::ShouldRemove

function ShouldBuildMore

virtual bool ShouldBuildMore(
    llarp_time_t now
) const

return true if we should build another path

Reimplemented by: llarp::exit::BaseSession::ShouldBuildMore, llarp::path::Builder::ShouldBuildMore, llarp::service::Endpoint::ShouldBuildMore, llarp::service::OutboundContext::ShouldBuildMore

function ShouldBuildMoreForRoles

virtual bool ShouldBuildMoreForRoles(
    llarp_time_t now,
    PathRole roles
) const

return true if we need another path with the given path roles

function MinRequiredForRoles

virtual size_t MinRequiredForRoles(
    PathRole roles
) const

return the minimum number of paths we want for given roles

function ShouldPublishDescriptors

inline virtual bool ShouldPublishDescriptors(
    llarp_time_t now
) const

return true if we should publish a new hidden service descriptor

Reimplemented by: llarp::service::Endpoint::ShouldPublishDescriptors

function BlacklistSNode

virtual void BlacklistSNode(
    const RouterID 
) =0

Reimplemented by: llarp::exit::BaseSession::BlacklistSNode, llarp::service::Endpoint::BlacklistSNode, llarp::service::OutboundContext::BlacklistSNode

function HandleGotIntroMessage

inline virtual bool HandleGotIntroMessage(
    std::shared_ptr< const dht::GotIntroMessage > 
)

override me in subtype

Reimplemented by: llarp::service::Endpoint::HandleGotIntroMessage

function HandleGotRouterMessage

inline virtual bool HandleGotRouterMessage(
    std::shared_ptr< const dht::GotRouterMessage > 
)

override me in subtype

Reimplemented by: llarp::service::Endpoint::HandleGotRouterMessage

function HandleGotNameMessage

inline virtual bool HandleGotNameMessage(
    std::shared_ptr< const dht::GotNameMessage > 
)

override me in subtype

Reimplemented by: llarp::service::Endpoint::HandleGotNameMessage

function GetDHTHandler

inline virtual routing::IMessageHandler * GetDHTHandler()

function GetEstablishedPathClosestTo

Path_ptr GetEstablishedPathClosestTo(
    RouterID router,
    std::unordered_set< RouterID > excluding ={},
    PathRole roles =ePathRoleAny
) const

function PickEstablishedPath

Path_ptr PickEstablishedPath(
    PathRole roles =ePathRoleAny
) const

function PickRandomEstablishedPath

Path_ptr PickRandomEstablishedPath(
    PathRole roles =ePathRoleAny
) const

function GetPathByRouter

Path_ptr GetPathByRouter(
    RouterID router,
    PathRole roles =ePathRoleAny
) const

function GetNewestPathByRouter

Path_ptr GetNewestPathByRouter(
    RouterID router,
    PathRole roles =ePathRoleAny
) const

function GetRandomPathByRouter

Path_ptr GetRandomPathByRouter(
    RouterID router,
    PathRole roles =ePathRoleAny
) const

function GetPathByID

Path_ptr GetPathByID(
    PathID_t id
) const

function GetByEndpointWithID

Path_ptr GetByEndpointWithID(
    RouterID router,
    PathID_t id
) const

function GetCurrentIntroductionsWithFilter

std::optional< std::set< service::Introduction > > GetCurrentIntroductionsWithFilter(
    std::function< bool(const service::Introduction &)> filter
) const

function PublishIntroSet

inline virtual bool PublishIntroSet(
    const service::EncryptedIntroSet & ,
    AbstractRouter * 
)

Reimplemented by: llarp::service::Endpoint::PublishIntroSet

function ResetInternalState

virtual void ResetInternalState() =0

reset all cooldown timers

Reimplemented by: llarp::exit::BaseSession::ResetInternalState, llarp::handlers::TunEndpoint::ResetInternalState, llarp::path::Builder::ResetInternalState, llarp::service::Endpoint::ResetInternalState

function BuildOneAlignedTo

virtual bool BuildOneAlignedTo(
    const RouterID endpoint
) =0

Reimplemented by: llarp::path::Builder::BuildOneAlignedTo

function SendPacketToRemote

virtual void SendPacketToRemote(
    const llarp_buffer_t & pkt,
    service::ProtocolType t
) =0

Reimplemented by: llarp::service::OutboundContext::SendPacketToRemote, llarp::handlers::NullEndpoint::SendPacketToRemote, llarp::handlers::TunEndpoint::SendPacketToRemote, llarp::exit::ExitSession::SendPacketToRemote, llarp::exit::SNodeSession::SendPacketToRemote

function GetHopsForBuild

virtual std::optional< std::vector< RouterContact > > GetHopsForBuild() =0

Reimplemented by: llarp::exit::BaseSession::GetHopsForBuild, llarp::path::Builder::GetHopsForBuild, llarp::service::Endpoint::GetHopsForBuild, llarp::service::OutboundContext::GetHopsForBuild

function ForEachPath

inline void ForEachPath(
    std::function< void(const Path_ptr &)> visit
) const

function UpstreamFlush

void UpstreamFlush(
    AbstractRouter * r
)

function DownstreamFlush

void DownstreamFlush(
    AbstractRouter * r
)

Protected Functions Documentation

function TickPaths

void TickPaths(
    AbstractRouter * r
)

Public Attributes Documentation

variable max_paths

static constexpr size_t max_paths = 32;

maximum number of paths a path set can maintain

variable numDesiredPaths

size_t numDesiredPaths;

Protected Attributes Documentation

variable m_BuildStats

BuildStats m_BuildStats;

variable m_PathsMutex

Mtx_t m_PathsMutex;

variable m_Paths

PathMap_t m_Paths;

Updated on 2026-01-10 at 22:49:45 +0000