pub struct HoprGraphPathSelector<G> {
me: OffchainPublicKey,
graph: G,
max_paths: usize,
}Expand description
A lightweight graph-backed path selector.
Returns all candidate paths for a (src, dest, hops) query directly from
the network graph — no caching is performed here. The caller (typically
crate::planner::PathPlanner) is responsible for caching, TTL management,
background refresh, and final path selection.
Stores the planner’s own identity (me) so that it can choose the
appropriate cost function:
- forward path (
src == me): [EdgeCostFn::forward] - return path (
dest == me): [EdgeCostFn::returning]
Fields§
§me: OffchainPublicKey§graph: G§max_paths: usizeImplementations§
Source§impl<G> HoprGraphPathSelector<G>
impl<G> HoprGraphPathSelector<G>
Trait Implementations§
Source§impl<G: Clone> Clone for HoprGraphPathSelector<G>
impl<G: Clone> Clone for HoprGraphPathSelector<G>
Source§fn clone(&self) -> HoprGraphPathSelector<G>
fn clone(&self) -> HoprGraphPathSelector<G>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<G> PathSelector for HoprGraphPathSelector<G>
impl<G> PathSelector for HoprGraphPathSelector<G>
Source§fn select_path(
&self,
src: OffchainPublicKey,
dest: OffchainPublicKey,
hops: usize,
) -> Result<Vec<PathWithCost>>
fn select_path( &self, src: OffchainPublicKey, dest: OffchainPublicKey, hops: usize, ) -> Result<Vec<PathWithCost>>
Return all candidate paths from src to dest via hops relays.
Each returned tuple contains a path Vec<OffchainPublicKey> of length
hops + 1 ([intermediates..., dest]; src excluded) paired with its
accumulated traversal cost.
Returns Err(PathNotFound) when the graph yields no positive-cost paths.
The function has a potential to run expensive operations, it should be benchmarked in a production environment and possibly guarded (e.g. by offloading the long execution in an async executor to avoid blocking the caller).
Auto Trait Implementations§
impl<G> Freeze for HoprGraphPathSelector<G>where
G: Freeze,
impl<G> RefUnwindSafe for HoprGraphPathSelector<G>where
G: RefUnwindSafe,
impl<G> Send for HoprGraphPathSelector<G>where
G: Send,
impl<G> Sync for HoprGraphPathSelector<G>where
G: Sync,
impl<G> Unpin for HoprGraphPathSelector<G>where
G: Unpin,
impl<G> UnwindSafe for HoprGraphPathSelector<G>where
G: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more