hopr_path/selectors/
mod.rs1pub mod dfs;
2
3use async_trait::async_trait;
4use std::ops::Add;
5
6use hopr_internal_types::prelude::*;
7use hopr_primitive_types::primitives::Address;
8
9use crate::channel_graph::ChannelEdge;
10use crate::errors::Result;
11use crate::path::ChannelPath;
12
13pub trait EdgeWeighting<W>
15where
16 W: Default + Add<W, Output = W>,
17{
18 fn calculate_weight(channel: &ChannelEdge) -> W;
20}
21
22#[async_trait]
24pub trait PathSelector {
25 async fn select_path(
29 &self,
30 source: Address,
31 destination: Address,
32 min_hops: usize,
33 max_hops: usize,
34 ) -> Result<ChannelPath>;
35
36 async fn select_auto_path(&self, source: Address, destination: Address) -> Result<ChannelPath> {
39 self.select_path(source, destination, 1usize, INTERMEDIATE_HOPS).await
40 }
41}