fix status response
This commit is contained in:
@@ -36,11 +36,15 @@ use stop_token::future::FutureExt;
|
||||
|
||||
type OperationId = u64;
|
||||
|
||||
/// Where to send an RPC message
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Destination {
|
||||
Direct(NodeRef), // Send to node (target noderef)
|
||||
Relay(NodeRef, DHTKey), // Send to node for relay purposes (relay noderef, target nodeid)
|
||||
PrivateRoute(PrivateRoute), // Send to private route (privateroute)
|
||||
/// Send to node (target noderef)
|
||||
Direct(NodeRef),
|
||||
/// Send to node for relay purposes (relay noderef, target nodeid)
|
||||
Relay(NodeRef, DHTKey),
|
||||
/// Send to private route (privateroute)
|
||||
PrivateRoute(PrivateRoute),
|
||||
}
|
||||
|
||||
impl fmt::Display for Destination {
|
||||
@@ -59,12 +63,19 @@ impl fmt::Display for Destination {
|
||||
}
|
||||
}
|
||||
|
||||
/// The decoded header of an RPC message
|
||||
#[derive(Debug, Clone)]
|
||||
struct RPCMessageHeader {
|
||||
timestamp: u64, // time the message was received, not sent
|
||||
/// Time the message was received, not sent
|
||||
timestamp: u64,
|
||||
/// The decoded header of the envelope
|
||||
envelope: Envelope,
|
||||
/// The length in bytes of the rpc message body
|
||||
body_len: u64,
|
||||
peer_noderef: NodeRef, // ensures node doesn't get evicted from routing table until we're done with it
|
||||
/// The noderef of the peer that sent the message (not the original sender). Ensures node doesn't get evicted from routing table until we're done with it
|
||||
peer_noderef: NodeRef,
|
||||
/// The connection from the peer sent the message (not the original sender)
|
||||
connection_descriptor: ConnectionDescriptor,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -993,6 +1004,7 @@ impl RPCProcessor {
|
||||
envelope: Envelope,
|
||||
body: Vec<u8>,
|
||||
peer_noderef: NodeRef,
|
||||
connection_descriptor: ConnectionDescriptor,
|
||||
) -> EyreResult<()> {
|
||||
let msg = RPCMessageEncoded {
|
||||
header: RPCMessageHeader {
|
||||
@@ -1000,6 +1012,7 @@ impl RPCProcessor {
|
||||
envelope,
|
||||
body_len: body.len() as u64,
|
||||
peer_noderef,
|
||||
connection_descriptor,
|
||||
},
|
||||
data: RPCMessageData { contents: body },
|
||||
};
|
||||
|
@@ -85,6 +85,7 @@ impl RPCProcessor {
|
||||
#[instrument(level = "trace", skip(self, msg), fields(msg.operation.op_id, res), err)]
|
||||
pub(crate) async fn process_status_q(&self, msg: RPCMessage) -> Result<(), RPCError> {
|
||||
let peer_noderef = msg.header.peer_noderef.clone();
|
||||
let connection_descriptor = msg.header.connection_descriptor;
|
||||
|
||||
// Get the question
|
||||
let status_q = match msg.operation.kind() {
|
||||
@@ -105,7 +106,12 @@ impl RPCProcessor {
|
||||
|
||||
// Make status answer
|
||||
let node_status = self.network_manager().generate_node_status();
|
||||
let sender_info = Self::generate_sender_info(peer_noderef).await;
|
||||
// Filter the noderef down to the protocol used by the incoming connection
|
||||
let filtered_peer_noderef =
|
||||
peer_noderef.filtered_clone(connection_descriptor.make_dial_info_filter());
|
||||
// Get the peer address in the returned sender info
|
||||
let sender_info = Self::generate_sender_info(filtered_peer_noderef).await;
|
||||
|
||||
let status_a = RPCOperationStatusA {
|
||||
node_status,
|
||||
sender_info,
|
||||
|
Reference in New Issue
Block a user