This commit is contained in:
Christien Rioux 2023-11-04 19:52:29 -04:00
parent 38cd29f9a1
commit ee1472f3ae
7 changed files with 86 additions and 68 deletions

View File

@ -167,6 +167,7 @@ impl RouteSpecStore {
/// Returns other errors on failure /// Returns other errors on failure
/// Returns Ok(route id string) on success /// Returns Ok(route id string) on success
#[instrument(level = "trace", skip(self), ret, err(level=Level::TRACE))] #[instrument(level = "trace", skip(self), ret, err(level=Level::TRACE))]
#[allow(clippy::too_many_arguments)]
pub fn allocate_route( pub fn allocate_route(
&self, &self,
crypto_kinds: &[CryptoKind], crypto_kinds: &[CryptoKind],
@ -175,6 +176,7 @@ impl RouteSpecStore {
hop_count: usize, hop_count: usize,
directions: DirectionSet, directions: DirectionSet,
avoid_nodes: &[TypedKey], avoid_nodes: &[TypedKey],
automatic: bool,
) -> VeilidAPIResult<RouteId> { ) -> VeilidAPIResult<RouteId> {
let inner = &mut *self.inner.lock(); let inner = &mut *self.inner.lock();
let routing_table = self.unlocked_inner.routing_table.clone(); let routing_table = self.unlocked_inner.routing_table.clone();
@ -189,6 +191,7 @@ impl RouteSpecStore {
hop_count, hop_count,
directions, directions,
avoid_nodes, avoid_nodes,
automatic,
) )
} }
@ -204,6 +207,7 @@ impl RouteSpecStore {
hop_count: usize, hop_count: usize,
directions: DirectionSet, directions: DirectionSet,
avoid_nodes: &[TypedKey], avoid_nodes: &[TypedKey],
automatic: bool,
) -> VeilidAPIResult<RouteId> { ) -> VeilidAPIResult<RouteId> {
use core::cmp::Ordering; use core::cmp::Ordering;
@ -576,6 +580,7 @@ impl RouteSpecStore {
directions, directions,
stability, stability,
can_do_sequenced, can_do_sequenced,
automatic,
); );
// make id // make id
@ -1255,6 +1260,7 @@ impl RouteSpecStore {
safety_spec.hop_count, safety_spec.hop_count,
direction, direction,
avoid_nodes, avoid_nodes,
true,
)? )?
}; };

View File

@ -29,6 +29,8 @@ pub(crate) struct RouteSetSpecDetail {
can_do_sequenced: bool, can_do_sequenced: bool,
/// Stats /// Stats
stats: RouteStats, stats: RouteStats,
/// Automatically allocated route vs manually allocated route
automatic: bool,
} }
impl RouteSetSpecDetail { impl RouteSetSpecDetail {
@ -39,6 +41,7 @@ impl RouteSetSpecDetail {
directions: DirectionSet, directions: DirectionSet,
stability: Stability, stability: Stability,
can_do_sequenced: bool, can_do_sequenced: bool,
automatic: bool,
) -> Self { ) -> Self {
Self { Self {
route_set, route_set,
@ -48,6 +51,7 @@ impl RouteSetSpecDetail {
stability, stability,
can_do_sequenced, can_do_sequenced,
stats: RouteStats::new(cur_ts), stats: RouteStats::new(cur_ts),
automatic,
} }
} }
pub fn get_route_by_key(&self, key: &PublicKey) -> Option<&RouteSpecDetail> { pub fn get_route_by_key(&self, key: &PublicKey) -> Option<&RouteSpecDetail> {
@ -115,6 +119,9 @@ impl RouteSetSpecDetail {
} }
false false
} }
pub fn is_automatic(&self) -> bool {
self.automatic
}
/// Generate a key for the cache that can be used to uniquely identify this route's contents /// Generate a key for the cache that can be used to uniquely identify this route's contents
pub fn make_cache_key(&self, rti: &RoutingTableInner) -> Vec<u8> { pub fn make_cache_key(&self, rti: &RoutingTableInner) -> Vec<u8> {

View File

@ -110,8 +110,10 @@ impl RouteSpecStoreCache {
self.invalidate_compiled_route_cache(pk); self.invalidate_compiled_route_cache(pk);
} }
// Mark it as dead for the update // Mark it as dead for the update if it wasn't automatically created
self.dead_routes.push(id); if !rssd.is_automatic() {
self.dead_routes.push(id);
}
true true
} }

View File

@ -219,6 +219,7 @@ impl RoutingTable {
default_route_hop_count, default_route_hop_count,
DirectionSet::all(), DirectionSet::all(),
&[], &[],
true,
) { ) {
Err(VeilidAPIError::TryAgain { message }) => { Err(VeilidAPIError::TryAgain { message }) => {
log_rtab!(debug "Route allocation unavailable: {}", message); log_rtab!(debug "Route allocation unavailable: {}", message);

View File

@ -270,6 +270,7 @@ impl VeilidAPI {
default_route_hop_count, default_route_hop_count,
Direction::Inbound.into(), Direction::Inbound.into(),
&[], &[],
false,
)?; )?;
if !rss.test_route(route_id).await? { if !rss.test_route(route_id).await? {
rss.release_route(route_id); rss.release_route(route_id);

View File

@ -1095,6 +1095,7 @@ impl VeilidAPI {
hop_count, hop_count,
directions, directions,
&[], &[],
false,
) { ) {
Ok(v) => v.to_string(), Ok(v) => v.to_string(),
Err(e) => { Err(e) => {

View File

@ -27,82 +27,82 @@ pub fn setup() -> () {
}); });
} }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_types() { async fn wasm_test_types() {
// setup(); setup();
// test_types::test_all().await; test_types::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_veilid_core() { async fn wasm_test_veilid_core() {
// setup(); setup();
// test_veilid_core::test_all().await; test_veilid_core::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_veilid_config() { async fn wasm_test_veilid_config() {
// setup(); setup();
// test_veilid_config::test_all().await; test_veilid_config::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_connection_table() { async fn wasm_test_connection_table() {
// setup(); setup();
// test_connection_table::test_all().await; test_connection_table::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_signed_node_info() { async fn wasm_test_signed_node_info() {
// setup(); setup();
// test_signed_node_info::test_all().await; test_signed_node_info::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_table_store() { async fn wasm_test_table_store() {
// setup(); setup();
// test_table_store::test_all().await; test_table_store::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_protected_store() { async fn wasm_test_protected_store() {
// setup(); setup();
// test_protected_store::test_all().await; test_protected_store::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_crypto() { async fn wasm_test_crypto() {
// setup(); setup();
// test_crypto::test_all().await; test_crypto::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_envelope_receipt() { async fn wasm_test_envelope_receipt() {
// setup(); setup();
// test_envelope_receipt::test_all().await; test_envelope_receipt::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_serialize_json() { async fn wasm_test_serialize_json() {
// setup(); setup();
// test_serialize_json::test_all().await; test_serialize_json::test_all().await;
// } }
// #[wasm_bindgen_test] #[wasm_bindgen_test]
// #[serial] #[serial]
// async fn wasm_test_serialize_routing_table() { async fn wasm_test_serialize_routing_table() {
// setup(); setup();
// test_serialize_routing_table::test_all().await; test_serialize_routing_table::test_all().await;
// } }
#[wasm_bindgen_test] #[wasm_bindgen_test]
#[serial] #[serial]