refactor
This commit is contained in:
@@ -64,7 +64,7 @@ pub struct RPCOperation {
|
||||
impl RPCOperation {
|
||||
pub fn new_question(question: RPCQuestion, sender_node_info: Option<SignedNodeInfo>) -> Self {
|
||||
Self {
|
||||
op_id: intf::get_random_u64(),
|
||||
op_id: get_random_u64(),
|
||||
sender_node_info,
|
||||
kind: RPCOperationKind::Question(question),
|
||||
}
|
||||
@@ -74,7 +74,7 @@ impl RPCOperation {
|
||||
sender_node_info: Option<SignedNodeInfo>,
|
||||
) -> Self {
|
||||
Self {
|
||||
op_id: intf::get_random_u64(),
|
||||
op_id: get_random_u64(),
|
||||
sender_node_info,
|
||||
kind: RPCOperationKind::Statement(statement),
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ pub use rpc_error::*;
|
||||
pub use rpc_status::*;
|
||||
|
||||
use super::*;
|
||||
|
||||
use crate::crypto::*;
|
||||
use crate::xx::*;
|
||||
use futures_util::StreamExt;
|
||||
@@ -256,7 +257,7 @@ impl RPCProcessor {
|
||||
let timeout = ms_to_us(c.network.rpc.timeout_ms);
|
||||
let max_route_hop_count = c.network.rpc.max_route_hop_count as usize;
|
||||
if concurrency == 0 {
|
||||
concurrency = intf::get_concurrency() / 2;
|
||||
concurrency = get_concurrency() / 2;
|
||||
if concurrency == 0 {
|
||||
concurrency = 1;
|
||||
}
|
||||
@@ -313,7 +314,7 @@ impl RPCProcessor {
|
||||
for _ in 0..self.unlocked_inner.concurrency {
|
||||
let this = self.clone();
|
||||
let receiver = channel.1.clone();
|
||||
let jh = intf::spawn(Self::rpc_worker(
|
||||
let jh = spawn(Self::rpc_worker(
|
||||
this,
|
||||
inner.stop_source.as_ref().unwrap().token(),
|
||||
receiver,
|
||||
@@ -460,7 +461,7 @@ impl RPCProcessor {
|
||||
}
|
||||
Ok(TimeoutOr::Value((rpcreader, _))) => {
|
||||
// Reply received
|
||||
let recv_ts = intf::get_timestamp();
|
||||
let recv_ts = get_timestamp();
|
||||
|
||||
// Record answer received
|
||||
self.record_answer_received(
|
||||
@@ -1011,7 +1012,7 @@ impl RPCProcessor {
|
||||
|
||||
// Send question
|
||||
let bytes = message.len() as u64;
|
||||
let send_ts = intf::get_timestamp();
|
||||
let send_ts = get_timestamp();
|
||||
let send_data_kind = network_result_try!(self
|
||||
.network_manager()
|
||||
.send_envelope(node_ref.clone(), Some(node_id), message)
|
||||
@@ -1078,7 +1079,7 @@ impl RPCProcessor {
|
||||
|
||||
// Send statement
|
||||
let bytes = message.len() as u64;
|
||||
let send_ts = intf::get_timestamp();
|
||||
let send_ts = get_timestamp();
|
||||
let _send_data_kind = network_result_try!(self
|
||||
.network_manager()
|
||||
.send_envelope(node_ref.clone(), Some(node_id), message)
|
||||
@@ -1139,7 +1140,7 @@ impl RPCProcessor {
|
||||
|
||||
// Send the reply
|
||||
let bytes = message.len() as u64;
|
||||
let send_ts = intf::get_timestamp();
|
||||
let send_ts = get_timestamp();
|
||||
network_result_try!(self.network_manager()
|
||||
.send_envelope(node_ref.clone(), Some(node_id), message)
|
||||
.await
|
||||
@@ -1357,7 +1358,7 @@ impl RPCProcessor {
|
||||
connection_descriptor,
|
||||
routing_domain,
|
||||
}),
|
||||
timestamp: intf::get_timestamp(),
|
||||
timestamp: get_timestamp(),
|
||||
body_len: body.len() as u64,
|
||||
},
|
||||
data: RPCMessageData { contents: body },
|
||||
@@ -1386,7 +1387,7 @@ impl RPCProcessor {
|
||||
remote_safety_route,
|
||||
sequencing,
|
||||
}),
|
||||
timestamp: intf::get_timestamp(),
|
||||
timestamp: get_timestamp(),
|
||||
body_len: body.len() as u64,
|
||||
},
|
||||
data: RPCMessageData { contents: body },
|
||||
@@ -1419,7 +1420,7 @@ impl RPCProcessor {
|
||||
safety_spec,
|
||||
},
|
||||
),
|
||||
timestamp: intf::get_timestamp(),
|
||||
timestamp: get_timestamp(),
|
||||
body_len: body.len() as u64,
|
||||
},
|
||||
data: RPCMessageData { contents: body },
|
||||
|
@@ -104,9 +104,9 @@ where
|
||||
pub async fn wait_for_op(
|
||||
&self,
|
||||
mut handle: OperationWaitHandle<T>,
|
||||
timeout: u64,
|
||||
timeout_us: u64,
|
||||
) -> Result<TimeoutOr<(T, u64)>, RPCError> {
|
||||
let timeout_ms = u32::try_from(timeout / 1000u64)
|
||||
let timeout_ms = u32::try_from(timeout_us / 1000u64)
|
||||
.map_err(|e| RPCError::map_internal("invalid timeout")(e))?;
|
||||
|
||||
// Take the instance
|
||||
@@ -114,8 +114,8 @@ where
|
||||
let eventual_instance = handle.eventual_instance.take().unwrap();
|
||||
|
||||
// wait for eventualvalue
|
||||
let start_ts = intf::get_timestamp();
|
||||
let res = intf::timeout(timeout_ms, eventual_instance)
|
||||
let start_ts = get_timestamp();
|
||||
let res = timeout(timeout_ms, eventual_instance)
|
||||
.await
|
||||
.into_timeout_or();
|
||||
Ok(res
|
||||
@@ -125,7 +125,7 @@ where
|
||||
})
|
||||
.map(|res| {
|
||||
let (_span_id, ret) = res.take_value().unwrap();
|
||||
let end_ts = intf::get_timestamp();
|
||||
let end_ts = get_timestamp();
|
||||
|
||||
//xxx: causes crash (Missing otel data span extensions)
|
||||
// Span::current().follows_from(span_id);
|
||||
|
Reference in New Issue
Block a user