mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-16 14:47:25 +08:00
fix peer center for latency report
This commit is contained in:
@@ -683,16 +683,18 @@ impl PeerRouteServiceImpl {
|
||||
DefaultRouteCostCalculator::default(),
|
||||
);
|
||||
|
||||
let calc_locked = self.cost_calculator.lock().unwrap();
|
||||
let mut calc_locked = self.cost_calculator.lock().unwrap();
|
||||
if calc_locked.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
calc_locked.as_mut().unwrap().begin_update();
|
||||
self.route_table_with_cost.build_from_synced_info(
|
||||
self.my_peer_id,
|
||||
&self.synced_route_info,
|
||||
&calc_locked.as_ref().unwrap(),
|
||||
calc_locked.as_mut().unwrap(),
|
||||
);
|
||||
calc_locked.as_mut().unwrap().end_update();
|
||||
}
|
||||
|
||||
fn cost_calculator_need_update(&self) -> bool {
|
||||
|
||||
@@ -31,8 +31,11 @@ pub trait RouteInterface {
|
||||
|
||||
pub type RouteInterfaceBox = Box<dyn RouteInterface + Send + Sync>;
|
||||
|
||||
#[auto_impl::auto_impl(Box, Arc, &)]
|
||||
#[auto_impl::auto_impl(Box , &mut)]
|
||||
pub trait RouteCostCalculatorInterface: Send + Sync {
|
||||
fn begin_update(&mut self) {}
|
||||
fn end_update(&mut self) {}
|
||||
|
||||
fn calculate_cost(&self, _src: PeerId, _dst: PeerId) -> i32 {
|
||||
1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user