pub trait PathSelector {
// Required method
fn select_path(
&self,
src: OffchainPublicKey,
dest: OffchainPublicKey,
hops: usize,
) -> Result<Vec<PathWithCost>>;
}Expand description
Selects multi-hop paths through the network.
Implementors are responsible for determining how paths are found.
The caller (e.g. crate::planner::PathPlanner) is responsible for caching,
path selection strategy, and validation.
§Cycle-free invariant
Implementations must return only cycle-free (simple) paths — no node may
appear more than once in any returned path. Cycles destroy path entropy and
worsen anonymity. The built-in crate::selector::HoprGraphPathSelector
guarantees this by using the simple_paths graph algorithm, which by
definition never revisits a node. Alternative implementations must uphold
the same invariant.
Required Methods§
Sourcefn 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 using hops relays.
Each returned PathWithCost contains a path Vec<OffchainPublicKey>
of length hops + 1 ([intermediates..., dest]; src excluded) paired
with its accumulated traversal cost.
Every returned path must be cycle-free (see trait-level docs).
Returns Err when no paths can be found.