more refactor checkpoint
This commit is contained in:
		@@ -25,7 +25,7 @@ impl RPCOperationKind {
 | 
			
		||||
        let out = match which_reader {
 | 
			
		||||
            veilid_capnp::operation::kind::Which::Question(r) => {
 | 
			
		||||
                let q_reader = r.map_err(RPCError::protocol)?;
 | 
			
		||||
                let out = RPCQuestion::decode(&q_reader, sender_node_id)?;
 | 
			
		||||
                let out = RPCQuestion::decode(&q_reader)?;
 | 
			
		||||
                RPCOperationKind::Question(out)
 | 
			
		||||
            }
 | 
			
		||||
            veilid_capnp::operation::kind::Which::Statement(r) => {
 | 
			
		||||
@@ -137,12 +137,12 @@ impl RPCOperation {
 | 
			
		||||
 | 
			
		||||
    pub fn encode(&self, builder: &mut veilid_capnp::operation::Builder) -> Result<(), RPCError> {
 | 
			
		||||
        builder.set_op_id(self.op_id);
 | 
			
		||||
        let mut k_builder = builder.reborrow().init_kind();
 | 
			
		||||
        self.kind.encode(&mut k_builder)?;
 | 
			
		||||
        if let Some(sender_info) = self.sender_node_info {
 | 
			
		||||
            let si_builder = builder.reborrow().init_sender_node_info();
 | 
			
		||||
        if let Some(sender_info) = &self.sender_node_info {
 | 
			
		||||
            let mut si_builder = builder.reborrow().init_sender_node_info();
 | 
			
		||||
            encode_signed_node_info(&sender_info, &mut si_builder)?;
 | 
			
		||||
        }
 | 
			
		||||
        let mut k_builder = builder.reborrow().init_kind();
 | 
			
		||||
        self.kind.encode(&mut k_builder)?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,10 +21,7 @@ impl RPCQuestion {
 | 
			
		||||
    pub fn desc(&self) -> &'static str {
 | 
			
		||||
        self.detail.desc()
 | 
			
		||||
    }
 | 
			
		||||
    pub fn decode(
 | 
			
		||||
        reader: &veilid_capnp::question::Reader,
 | 
			
		||||
        sender_node_id: &DHTKey,
 | 
			
		||||
    ) -> Result<RPCQuestion, RPCError> {
 | 
			
		||||
    pub fn decode(reader: &veilid_capnp::question::Reader) -> Result<RPCQuestion, RPCError> {
 | 
			
		||||
        let rt_reader = reader.get_respond_to();
 | 
			
		||||
        let respond_to = RespondTo::decode(&rt_reader)?;
 | 
			
		||||
        let d_reader = reader.get_detail();
 | 
			
		||||
 
 | 
			
		||||
@@ -103,16 +103,16 @@ impl Destination {
 | 
			
		||||
    pub fn safety_route_spec(&self) -> Option<Arc<SafetyRouteSpec>> {
 | 
			
		||||
        match self {
 | 
			
		||||
            Destination::Direct {
 | 
			
		||||
                target,
 | 
			
		||||
                target: _,
 | 
			
		||||
                safety_route_spec,
 | 
			
		||||
            } => safety_route_spec.clone(),
 | 
			
		||||
            Destination::Relay {
 | 
			
		||||
                relay,
 | 
			
		||||
                target,
 | 
			
		||||
                relay: _,
 | 
			
		||||
                target: _,
 | 
			
		||||
                safety_route_spec,
 | 
			
		||||
            } => safety_route_spec.clone(),
 | 
			
		||||
            Destination::PrivateRoute {
 | 
			
		||||
                private_route,
 | 
			
		||||
                private_route: _,
 | 
			
		||||
                safety_route_spec,
 | 
			
		||||
            } => safety_route_spec.clone(),
 | 
			
		||||
        }
 | 
			
		||||
@@ -154,6 +154,7 @@ impl fmt::Display for Destination {
 | 
			
		||||
                safety_route_spec,
 | 
			
		||||
            } => {
 | 
			
		||||
                let sr = safety_route_spec
 | 
			
		||||
                    .as_ref()
 | 
			
		||||
                    .map(|_sr| "+SR".to_owned())
 | 
			
		||||
                    .unwrap_or_default();
 | 
			
		||||
 | 
			
		||||
@@ -165,6 +166,7 @@ impl fmt::Display for Destination {
 | 
			
		||||
                safety_route_spec,
 | 
			
		||||
            } => {
 | 
			
		||||
                let sr = safety_route_spec
 | 
			
		||||
                    .as_ref()
 | 
			
		||||
                    .map(|_sr| "+SR".to_owned())
 | 
			
		||||
                    .unwrap_or_default();
 | 
			
		||||
 | 
			
		||||
@@ -175,6 +177,7 @@ impl fmt::Display for Destination {
 | 
			
		||||
                safety_route_spec,
 | 
			
		||||
            } => {
 | 
			
		||||
                let sr = safety_route_spec
 | 
			
		||||
                    .as_ref()
 | 
			
		||||
                    .map(|_sr| "+SR".to_owned())
 | 
			
		||||
                    .unwrap_or_default();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -323,7 +323,7 @@ impl RPCProcessor {
 | 
			
		||||
            .await
 | 
			
		||||
            .into_timeout_or();
 | 
			
		||||
        Ok(res.map(|res| {
 | 
			
		||||
            let (span_id, rpcreader) = res.take_value().unwrap();
 | 
			
		||||
            let (_span_id, rpcreader) = res.take_value().unwrap();
 | 
			
		||||
            let end_ts = intf::get_timestamp();
 | 
			
		||||
 | 
			
		||||
            // fixme: causes crashes? "Missing otel data span extensions"??
 | 
			
		||||
@@ -385,13 +385,13 @@ impl RPCProcessor {
 | 
			
		||||
        // To where are we sending the request
 | 
			
		||||
        match dest {
 | 
			
		||||
            Destination::Direct {
 | 
			
		||||
                target: node_ref,
 | 
			
		||||
                safety_route_spec,
 | 
			
		||||
                target: ref node_ref,
 | 
			
		||||
                ref safety_route_spec,
 | 
			
		||||
            }
 | 
			
		||||
            | Destination::Relay {
 | 
			
		||||
                relay: node_ref,
 | 
			
		||||
                relay: ref node_ref,
 | 
			
		||||
                target: _,
 | 
			
		||||
                safety_route_spec,
 | 
			
		||||
                ref safety_route_spec,
 | 
			
		||||
            } => {
 | 
			
		||||
                // Send to a node without a private route
 | 
			
		||||
                // --------------------------------------
 | 
			
		||||
@@ -399,7 +399,7 @@ impl RPCProcessor {
 | 
			
		||||
                // Get the actual destination node id accounting for relays
 | 
			
		||||
                let (node_ref, node_id) = if let Destination::Relay {
 | 
			
		||||
                    relay: _,
 | 
			
		||||
                    target: dht_key,
 | 
			
		||||
                    target: ref dht_key,
 | 
			
		||||
                    safety_route_spec: _,
 | 
			
		||||
                } = dest
 | 
			
		||||
                {
 | 
			
		||||
@@ -410,7 +410,7 @@ impl RPCProcessor {
 | 
			
		||||
                };
 | 
			
		||||
 | 
			
		||||
                // Handle the existence of safety route
 | 
			
		||||
                match safety_route_spec {
 | 
			
		||||
                match safety_route_spec.as_ref() {
 | 
			
		||||
                    None => {
 | 
			
		||||
                        // If no safety route is being used, and we're not sending to a private
 | 
			
		||||
                        // route, we can use a direct envelope instead of routing
 | 
			
		||||
@@ -434,7 +434,8 @@ impl RPCProcessor {
 | 
			
		||||
                            .dial_info
 | 
			
		||||
                            .node_id
 | 
			
		||||
                            .key;
 | 
			
		||||
                        out_message = self.wrap_with_route(Some(sr), private_route, message_vec)?;
 | 
			
		||||
                        out_message =
 | 
			
		||||
                            self.wrap_with_route(Some(sr.clone()), private_route, message_vec)?;
 | 
			
		||||
                        out_hop_count = 1 + sr.hops.len();
 | 
			
		||||
                    }
 | 
			
		||||
                };
 | 
			
		||||
@@ -892,7 +893,7 @@ impl RPCProcessor {
 | 
			
		||||
        stop_token: StopToken,
 | 
			
		||||
        receiver: flume::Receiver<(Option<Id>, RPCMessageEncoded)>,
 | 
			
		||||
    ) {
 | 
			
		||||
        while let Ok(Ok((span_id, msg))) =
 | 
			
		||||
        while let Ok(Ok((_span_id, msg))) =
 | 
			
		||||
            receiver.recv_async().timeout_at(stop_token.clone()).await
 | 
			
		||||
        {
 | 
			
		||||
            let rpc_worker_span = span!(parent: None, Level::TRACE, "rpc_worker");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user