llarp::path::Builder

Inherits from llarp::path::PathSet

Inherited by llarp::exit::BaseSession, llarp::service::Endpoint, llarp::service::OutboundContext

Public Functions

Name
Builder(AbstractRouter * p_router, size_t numDesiredPaths, size_t numHops)
construct
virtual ~Builder() =default
virtual bool ShouldBuildMore(llarp_time_t now) const override
return true if we should build another path
virtual bool ShouldBundleRC() const =0
should we bundle RCs in builds?
virtual void ResetInternalState() override
reset all cooldown timers
bool BuildCooldownHit(llarp_time_t now) const
return true if we hit our soft limit for building paths too fast
virtual PathRole GetRoles() const
get roles for this path builder
BuildStats CurrentBuildStats() const
virtual bool Stop() override
stop this pathset and mark it as to be removed
virtual bool IsStopped() const override
return true if we are stopped
virtual bool ShouldRemove() const override
return true if we can and should remove this pathset and underlying resources from its parent context
virtual llarp_time_t Now() const override
get time from event loop
virtual void Tick(llarp_time_t now) override
tick owned paths
virtual void BuildOne(PathRole roles =ePathRoleAny) override
virtual bool BuildOneAlignedTo(const RouterID endpoint) override
std::optional< std::vector< RouterContact > > GetHopsAlignedToForBuild(RouterID endpoint, const std::set< RouterID > & exclude ={})
virtual void Build(std::vector< RouterContact > hops, PathRole roles =ePathRoleAny) override
manual build on these hops
std::optional< RouterContact > SelectFirstHop(const std::set< RouterID > & exclude ={}) const
pick a first hop
virtual std::optional< std::vector< RouterContact > > GetHopsForBuild() override
void ManualRebuild(size_t N, PathRole roles =ePathRoleAny)
virtual const SecretKey & GetTunnelEncryptionSecretKey() const
virtual void HandlePathBuilt(Path_ptr p) override
virtual void HandlePathBuildTimeout(Path_ptr p) override
virtual void HandlePathBuildFailedAt(Path_ptr p, RouterID hop) override

Protected Functions

Name
virtual bool UrgentBuild(llarp_time_t now) const
bool BuildCooldownHit(RouterID edge) const
return true if we hit our soft limit for building paths too fast on a first hop

Public Attributes

Name
AbstractRouter *const m_router
SecretKey enckey
size_t numHops
llarp_time_t lastBuild
llarp_time_t buildIntervalLimit

Protected Attributes

Name
std::atomic< bool > _run
flag for PathSet::Stop()

Additional inherited members

Protected Types inherited from llarp::path::PathSet

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 inherited from llarp::path::PathSet

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
size_t NumPathsExistingAt(llarp_time_t futureTime) const
count the number of paths that will exist at this timestamp in future
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 std::string Name() const =0
get the "name" of this pathset
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 SendPacketToRemote(const llarp_buffer_t & pkt, service::ProtocolType t) =0
void ForEachPath(std::function< void(const Path_ptr &)> visit) const
void UpstreamFlush(AbstractRouter * r)
void DownstreamFlush(AbstractRouter * r)

Protected Functions inherited from llarp::path::PathSet

Name
void TickPaths(AbstractRouter * r)

Public Attributes inherited from llarp::path::PathSet

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

Protected Attributes inherited from llarp::path::PathSet

Name
BuildStats m_BuildStats
Mtx_t m_PathsMutex
PathMap_t m_Paths

Public Functions Documentation

function Builder

Builder(
    AbstractRouter * p_router,
    size_t numDesiredPaths,
    size_t numHops
)

construct

function ~Builder

virtual ~Builder() =default

function ShouldBuildMore

virtual bool ShouldBuildMore(
    llarp_time_t now
) const override

return true if we should build another path

Reimplements: llarp::path::PathSet::ShouldBuildMore

Reimplemented by: llarp::service::Endpoint::ShouldBuildMore, llarp::service::OutboundContext::ShouldBuildMore

function ShouldBundleRC

virtual bool ShouldBundleRC() const =0

should we bundle RCs in builds?

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

function ResetInternalState

virtual void ResetInternalState() override

reset all cooldown timers

Reimplements: llarp::path::PathSet::ResetInternalState

Reimplemented by: llarp::handlers::TunEndpoint::ResetInternalState, llarp::service::Endpoint::ResetInternalState

function BuildCooldownHit

bool BuildCooldownHit(
    llarp_time_t now
) const

return true if we hit our soft limit for building paths too fast

function GetRoles

inline virtual PathRole GetRoles() const

get roles for this path builder

Reimplemented by: llarp::exit::BaseSession::GetRoles

function CurrentBuildStats

inline BuildStats CurrentBuildStats() const

function Stop

virtual bool Stop() override

stop this pathset and mark it as to be removed

Reimplements: llarp::path::PathSet::Stop

Reimplemented by: llarp::handlers::TunEndpoint::Stop, llarp::service::Endpoint::Stop, llarp::service::OutboundContext::Stop

function IsStopped

virtual bool IsStopped() const override

return true if we are stopped

Reimplements: llarp::path::PathSet::IsStopped

function ShouldRemove

virtual bool ShouldRemove() const override

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

Reimplements: llarp::path::PathSet::ShouldRemove

function Now

virtual llarp_time_t Now() const override

get time from event loop

Reimplements: llarp::path::PathSet::Now

function Tick

virtual void Tick(
    llarp_time_t now
) override

tick owned paths

Reimplements: llarp::path::PathSet::Tick

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

function BuildOne

virtual void BuildOne(
    PathRole roles =ePathRoleAny
) override

Reimplements: llarp::path::PathSet::BuildOne

function BuildOneAlignedTo

virtual bool BuildOneAlignedTo(
    const RouterID endpoint
) override

Reimplements: llarp::path::PathSet::BuildOneAlignedTo

function GetHopsAlignedToForBuild

std::optional< std::vector< RouterContact > > GetHopsAlignedToForBuild(
    RouterID endpoint,
    const std::set< RouterID > & exclude ={}
)

function Build

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

manual build on these hops

Reimplements: llarp::path::PathSet::Build

function SelectFirstHop

std::optional< RouterContact > SelectFirstHop(
    const std::set< RouterID > & exclude ={}
) const

pick a first hop

function GetHopsForBuild

virtual std::optional< std::vector< RouterContact > > GetHopsForBuild() override

Reimplements: llarp::path::PathSet::GetHopsForBuild

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

function ManualRebuild

void ManualRebuild(
    size_t N,
    PathRole roles =ePathRoleAny
)

function GetTunnelEncryptionSecretKey

virtual const SecretKey & GetTunnelEncryptionSecretKey() const

function HandlePathBuilt

virtual void HandlePathBuilt(
    Path_ptr p
) override

Reimplements: llarp::path::PathSet::HandlePathBuilt

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

function HandlePathBuildTimeout

virtual void HandlePathBuildTimeout(
    Path_ptr p
) override

Reimplements: llarp::path::PathSet::HandlePathBuildTimeout

Reimplemented by: llarp::service::OutboundContext::HandlePathBuildTimeout

function HandlePathBuildFailedAt

virtual void HandlePathBuildFailedAt(
    Path_ptr p,
    RouterID hop
) override

Reimplements: llarp::path::PathSet::HandlePathBuildFailedAt

Reimplemented by: llarp::service::OutboundContext::HandlePathBuildFailedAt

Protected Functions Documentation

function UrgentBuild

virtual bool UrgentBuild(
    llarp_time_t now
) const

Reimplemented by: llarp::exit::BaseSession::UrgentBuild

function BuildCooldownHit

bool BuildCooldownHit(
    RouterID edge
) const

return true if we hit our soft limit for building paths too fast on a first hop

Public Attributes Documentation

variable m_router

AbstractRouter *const m_router;

variable enckey

SecretKey enckey;

variable numHops

size_t numHops;

variable lastBuild

llarp_time_t lastBuild = 0s;

variable buildIntervalLimit

llarp_time_t buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;

Protected Attributes Documentation

variable _run

std::atomic< bool > _run;

flag for PathSet::Stop()


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