pub trait RoutingStrategy: Send + Sync {
// Required methods
fn find_path<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn route_score(&self, neighbor: &NodeId, target: &NodeId) -> f64;
fn update_metrics(&mut self, path: &[NodeId], success: bool);
// Provided method
fn find_closest_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
content_hash: &'life1 ContentHash,
_count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Routing strategy trait for different routing algorithms
Required Methods§
Sourcefn find_path<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_path<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 NodeId,
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find a path to the target node
Sourcefn route_score(&self, neighbor: &NodeId, target: &NodeId) -> f64
fn route_score(&self, neighbor: &NodeId, target: &NodeId) -> f64
Calculate routing score for a neighbor towards a target
Sourcefn update_metrics(&mut self, path: &[NodeId], success: bool)
fn update_metrics(&mut self, path: &[NodeId], success: bool)
Update routing metrics based on success/failure
Provided Methods§
Sourcefn find_closest_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
content_hash: &'life1 ContentHash,
_count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_closest_nodes<'life0, 'life1, 'async_trait>(
&'life0 self,
content_hash: &'life1 ContentHash,
_count: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<NodeId>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Find closest nodes to a content hash