appreply
This commit is contained in:
parent
28b08034f5
commit
a5e17a0d65
@ -434,6 +434,11 @@ impl RPCProcessor {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/// Get waiting app call id for debugging purposes
|
||||||
|
pub fn get_app_call_ids(&self) -> Vec<OperationId> {
|
||||||
|
self.unlocked_inner.waiting_app_call_table.get_operation_ids()
|
||||||
|
}
|
||||||
|
|
||||||
/// Determine if a SignedNodeInfo can be placed into the specified routing domain
|
/// Determine if a SignedNodeInfo can be placed into the specified routing domain
|
||||||
fn verify_node_info(
|
fn verify_node_info(
|
||||||
&self,
|
&self,
|
||||||
|
@ -30,6 +30,7 @@ where
|
|||||||
C: Unpin + Clone,
|
C: Unpin + Clone,
|
||||||
{
|
{
|
||||||
context: C,
|
context: C,
|
||||||
|
timestamp: Timestamp,
|
||||||
eventual: EventualValue<(Option<Id>, T)>,
|
eventual: EventualValue<(Option<Id>, T)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ where
|
|||||||
let e = EventualValue::new();
|
let e = EventualValue::new();
|
||||||
let waiting_op = OperationWaitingOp {
|
let waiting_op = OperationWaitingOp {
|
||||||
context,
|
context,
|
||||||
|
timestamp: get_aligned_timestamp(),
|
||||||
eventual: e.clone(),
|
eventual: e.clone(),
|
||||||
};
|
};
|
||||||
if inner.waiting_op_table.insert(op_id, waiting_op).is_some() {
|
if inner.waiting_op_table.insert(op_id, waiting_op).is_some() {
|
||||||
@ -98,6 +100,18 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get all waiting operation ids
|
||||||
|
pub fn get_operation_ids(&self) -> Vec<OperationId> {
|
||||||
|
let inner = self.inner.lock();
|
||||||
|
let mut opids: Vec<(OperationId, Timestamp)> = inner
|
||||||
|
.waiting_op_table
|
||||||
|
.iter()
|
||||||
|
.map(|x| (*x.0, x.1.timestamp))
|
||||||
|
.collect();
|
||||||
|
opids.sort_by(|a, b| a.1.cmp(&b.1));
|
||||||
|
opids.into_iter().map(|x| x.0).collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Get operation context
|
/// Get operation context
|
||||||
pub fn get_op_context(&self, op_id: OperationId) -> Result<C, RPCError> {
|
pub fn get_op_context(&self, op_id: OperationId) -> Result<C, RPCError> {
|
||||||
let inner = self.inner.lock();
|
let inner = self.inner.lock();
|
||||||
|
@ -920,6 +920,37 @@ impl VeilidAPI {
|
|||||||
Ok(out)
|
Ok(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn debug_app_reply(&self, args: String) -> VeilidAPIResult<String> {
|
||||||
|
let netman = self.network_manager()?;
|
||||||
|
let rpc = netman.rpc_processor();
|
||||||
|
|
||||||
|
let (call_id, data) = if args.starts_with("#") {
|
||||||
|
let (arg, rest) = args[1..].split_once(' ').unwrap_or((&args, ""));
|
||||||
|
let call_id =
|
||||||
|
OperationId::new(u64::from_str_radix(arg, 16).map_err(VeilidAPIError::generic)?);
|
||||||
|
let rest = rest.trim_start().to_owned();
|
||||||
|
let data = get_debug_argument(&rest, "debug_app_reply", "data", get_data)?;
|
||||||
|
(call_id, data)
|
||||||
|
} else {
|
||||||
|
let call_id = rpc
|
||||||
|
.get_app_call_ids()
|
||||||
|
.first()
|
||||||
|
.cloned()
|
||||||
|
.ok_or_else(|| VeilidAPIError::generic("no app calls waiting"))?;
|
||||||
|
let data = get_debug_argument(&args, "debug_app_reply", "data", get_data)?;
|
||||||
|
(call_id, data)
|
||||||
|
};
|
||||||
|
|
||||||
|
let data_len = data.len();
|
||||||
|
|
||||||
|
// Send a AppCall Reply
|
||||||
|
self.app_call_reply(call_id, data)
|
||||||
|
.await
|
||||||
|
.map_err(VeilidAPIError::internal)?;
|
||||||
|
|
||||||
|
Ok(format!("Replied with {} bytes", data_len))
|
||||||
|
}
|
||||||
|
|
||||||
async fn debug_route_allocate(&self, args: Vec<String>) -> VeilidAPIResult<String> {
|
async fn debug_route_allocate(&self, args: Vec<String>) -> VeilidAPIResult<String> {
|
||||||
// [ord|*ord] [rel] [<count>] [in|out] [avoid_node_id]
|
// [ord|*ord] [rel] [<count>] [in|out] [avoid_node_id]
|
||||||
|
|
||||||
@ -1538,6 +1569,7 @@ contact <node>[<modifiers>]
|
|||||||
ping <destination>
|
ping <destination>
|
||||||
appmessage <destination> <data>
|
appmessage <destination> <data>
|
||||||
appcall <destination> <data>
|
appcall <destination> <data>
|
||||||
|
appreply [#id] <data>
|
||||||
relay <relay> [public|local]
|
relay <relay> [public|local]
|
||||||
punish list
|
punish list
|
||||||
route allocate [ord|*ord] [rel] [<count>] [in|out]
|
route allocate [ord|*ord] [rel] [<count>] [in|out]
|
||||||
@ -1619,6 +1651,8 @@ record list <local|remote>
|
|||||||
self.debug_app_message(rest).await
|
self.debug_app_message(rest).await
|
||||||
} else if arg == "appcall" {
|
} else if arg == "appcall" {
|
||||||
self.debug_app_call(rest).await
|
self.debug_app_call(rest).await
|
||||||
|
} else if arg == "appreply" {
|
||||||
|
self.debug_app_reply(rest).await
|
||||||
} else if arg == "contact" {
|
} else if arg == "contact" {
|
||||||
self.debug_contact(rest).await
|
self.debug_contact(rest).await
|
||||||
} else if arg == "nodeinfo" {
|
} else if arg == "nodeinfo" {
|
||||||
|
Loading…
Reference in New Issue
Block a user