refactor checkpoint

This commit is contained in:
John Smith
2022-09-04 14:17:28 -04:00
parent e0a5b1bd69
commit 79cda4a712
25 changed files with 531 additions and 398 deletions

View File

@@ -304,25 +304,41 @@ impl VeilidAPI {
None => return Ok("Node id not found in routing table".to_owned()),
};
if args.len() >= 2 {
let pt = get_debug_argument_at(
let mut ai = 1;
let mut routing_domain = None;
while ai < args.len() {
if let Ok(pt) = get_debug_argument_at(
&args,
1,
ai,
"debug_contact",
"protocol_type",
get_protocol_type,
)?;
nr.merge_filter(DialInfoFilter::all().with_protocol_type(pt));
if args.len() >= 3 {
let at = get_debug_argument_at(
&args,
2,
"debug_contact",
"address_type",
get_address_type,
)?;
nr.merge_filter(DialInfoFilter::all().with_address_type(at));
) {
nr.merge_filter(NodeRefFilter::new().with_protocol_type(pt));
} else if let Ok(at) =
get_debug_argument_at(&args, ai, "debug_contact", "address_type", get_address_type)
{
nr.merge_filter(NodeRefFilter::new().with_address_type(at));
} else if let Ok(rd) = get_debug_argument_at(
&args,
ai,
"debug_contact",
"routing_domain",
get_routing_domain,
) {
if routing_domain.is_none() {
routing_domain = Some(rd);
} else {
return Ok("Multiple routing domains specified".to_owned());
}
} else {
return Ok(format!("Invalid argument specified: {}", args[ai]));
}
ai += 1;
}
if let Some(routing_domain) = routing_domain {
nr.merge_filter(NodeRefFilter::new().with_routing_domain(routing_domain))
}
let cm = network_manager.get_contact_method(nr);
@@ -331,11 +347,14 @@ impl VeilidAPI {
}
async fn debug_ping(&self, args: String) -> Result<String, VeilidAPIError> {
let netman = self.network_manager()?;
let routing_table = netman.routing_table();
let rpc = netman.rpc_processor();
let args: Vec<String> = args.split_whitespace().map(|s| s.to_owned()).collect();
let node_id = get_debug_argument_at(&args, 0, "debug_ping", "node_id", get_dht_key)?;
let routing_table = self.network_manager()?.routing_table();
let mut nr = match routing_table.lookup_node_ref(node_id) {
Some(nr) => nr,
None => return Ok("Node id not found in routing table".to_owned()),
@@ -347,11 +366,11 @@ impl VeilidAPI {
if let Ok(pt) =
get_debug_argument_at(&args, ai, "debug_ping", "protocol_type", get_protocol_type)
{
nr.merge_filter(DialInfoFilter::all().with_protocol_type(pt));
nr.merge_filter(NodeRefFilter::new().with_protocol_type(pt));
} else if let Ok(at) =
get_debug_argument_at(&args, ai, "debug_ping", "address_type", get_address_type)
{
nr.merge_filter(DialInfoFilter::all().with_address_type(at));
nr.merge_filter(NodeRefFilter::new().with_address_type(at));
} else if let Ok(rd) = get_debug_argument_at(
&args,
ai,
@@ -370,11 +389,13 @@ impl VeilidAPI {
ai += 1;
}
let rpc = self.network_manager()?.rpc_processor();
if let Some(routing_domain) = routing_domain {
nr.merge_filter(NodeRefFilter::new().with_routing_domain(routing_domain))
}
// Dump routing table entry
let out = match rpc
.rpc_call_status(routing_domain, nr)
.rpc_call_status(nr)
.await
.map_err(VeilidAPIError::internal)?
{