appreply
This commit is contained in:
		@@ -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
 | 
			
		||||
    fn verify_node_info(
 | 
			
		||||
        &self,
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@ where
 | 
			
		||||
    C: Unpin + Clone,
 | 
			
		||||
{
 | 
			
		||||
    context: C,
 | 
			
		||||
    timestamp: Timestamp,
 | 
			
		||||
    eventual: EventualValue<(Option<Id>, T)>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -82,6 +83,7 @@ where
 | 
			
		||||
        let e = EventualValue::new();
 | 
			
		||||
        let waiting_op = OperationWaitingOp {
 | 
			
		||||
            context,
 | 
			
		||||
            timestamp: get_aligned_timestamp(),
 | 
			
		||||
            eventual: e.clone(),
 | 
			
		||||
        };
 | 
			
		||||
        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
 | 
			
		||||
    pub fn get_op_context(&self, op_id: OperationId) -> Result<C, RPCError> {
 | 
			
		||||
        let inner = self.inner.lock();
 | 
			
		||||
 
 | 
			
		||||
@@ -920,6 +920,37 @@ impl VeilidAPI {
 | 
			
		||||
        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> {
 | 
			
		||||
        // [ord|*ord] [rel] [<count>] [in|out] [avoid_node_id]
 | 
			
		||||
 | 
			
		||||
@@ -1538,6 +1569,7 @@ contact <node>[<modifiers>]
 | 
			
		||||
ping <destination>
 | 
			
		||||
appmessage <destination> <data>
 | 
			
		||||
appcall <destination> <data>
 | 
			
		||||
appreply [#id] <data>
 | 
			
		||||
relay <relay> [public|local]
 | 
			
		||||
punish list
 | 
			
		||||
route allocate [ord|*ord] [rel] [<count>] [in|out]
 | 
			
		||||
@@ -1619,6 +1651,8 @@ record list <local|remote>
 | 
			
		||||
                self.debug_app_message(rest).await
 | 
			
		||||
            } else if arg == "appcall" {
 | 
			
		||||
                self.debug_app_call(rest).await
 | 
			
		||||
            } else if arg == "appreply" {
 | 
			
		||||
                self.debug_app_reply(rest).await
 | 
			
		||||
            } else if arg == "contact" {
 | 
			
		||||
                self.debug_contact(rest).await
 | 
			
		||||
            } else if arg == "nodeinfo" {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user