route work
This commit is contained in:
parent
8d80fbb228
commit
e2b4e1fb76
@ -14,20 +14,19 @@ impl RoutingTable {
|
|||||||
stop_token: StopToken,
|
stop_token: StopToken,
|
||||||
routes_needing_testing: Vec<DHTKey>,
|
routes_needing_testing: Vec<DHTKey>,
|
||||||
) -> EyreResult<()> {
|
) -> EyreResult<()> {
|
||||||
let rss = self.route_spec_store();
|
if routes_needing_testing.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
log_rtab!(debug "Testing routes: {:?}", routes_needing_testing);
|
log_rtab!(debug "Testing routes: {:?}", routes_needing_testing);
|
||||||
|
|
||||||
|
// Test all the routes that need testing at the same time
|
||||||
|
let rss = self.route_spec_store();
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
struct TestRouteContext {
|
struct TestRouteContext {
|
||||||
failed: bool,
|
failed: bool,
|
||||||
dead_routes: Vec<DHTKey>,
|
dead_routes: Vec<DHTKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
if routes_needing_testing.is_empty() {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test all the routes that need testing at the same time
|
|
||||||
let mut unord = FuturesUnordered::new();
|
let mut unord = FuturesUnordered::new();
|
||||||
let ctx = Arc::new(Mutex::new(TestRouteContext::default()));
|
let ctx = Arc::new(Mutex::new(TestRouteContext::default()));
|
||||||
for r in routes_needing_testing {
|
for r in routes_needing_testing {
|
||||||
@ -97,8 +96,10 @@ impl RoutingTable {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if !routes_needing_testing.is_empty() {
|
||||||
self.test_route_set(stop_token.clone(), routes_needing_testing)
|
self.test_route_set(stop_token.clone(), routes_needing_testing)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure we have a minimum of N allocated local, unpublished routes with the default number of hops
|
// Ensure we have a minimum of N allocated local, unpublished routes with the default number of hops
|
||||||
let default_route_hop_count =
|
let default_route_hop_count =
|
||||||
@ -130,9 +131,11 @@ impl RoutingTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Immediately test them
|
// Immediately test them
|
||||||
|
if !newly_allocated_routes.is_empty() {
|
||||||
self.test_route_set(stop_token.clone(), newly_allocated_routes)
|
self.test_route_set(stop_token.clone(), newly_allocated_routes)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test remote routes next
|
// Test remote routes next
|
||||||
let remote_routes_needing_testing = rss.list_remote_routes(|k, v| {
|
let remote_routes_needing_testing = rss.list_remote_routes(|k, v| {
|
||||||
@ -143,8 +146,10 @@ impl RoutingTable {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if !remote_routes_needing_testing.is_empty() {
|
||||||
self.test_route_set(stop_token.clone(), remote_routes_needing_testing)
|
self.test_route_set(stop_token.clone(), remote_routes_needing_testing)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
// Send update (also may send updates for released routes done by other parts of the program)
|
// Send update (also may send updates for released routes done by other parts of the program)
|
||||||
rss.send_route_update();
|
rss.send_route_update();
|
||||||
|
Loading…
Reference in New Issue
Block a user