alignment refactor
This commit is contained in:
@@ -9,7 +9,7 @@ impl RPCOperationCancelTunnelQ {
|
||||
pub fn decode(
|
||||
reader: &veilid_capnp::operation_cancel_tunnel_q::Reader,
|
||||
) -> Result<RPCOperationCancelTunnelQ, RPCError> {
|
||||
let id = reader.get_id();
|
||||
let id = TunnelId::new(reader.get_id());
|
||||
|
||||
Ok(RPCOperationCancelTunnelQ { id })
|
||||
}
|
||||
@@ -17,7 +17,7 @@ impl RPCOperationCancelTunnelQ {
|
||||
&self,
|
||||
builder: &mut veilid_capnp::operation_cancel_tunnel_q::Builder,
|
||||
) -> Result<(), RPCError> {
|
||||
builder.set_id(self.id);
|
||||
builder.set_id(self.id.as_u64());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -35,7 +35,7 @@ impl RPCOperationCancelTunnelA {
|
||||
) -> Result<RPCOperationCancelTunnelA, RPCError> {
|
||||
match reader.which().map_err(RPCError::protocol)? {
|
||||
veilid_capnp::operation_cancel_tunnel_a::Which::Tunnel(r) => {
|
||||
Ok(RPCOperationCancelTunnelA::Tunnel(r))
|
||||
Ok(RPCOperationCancelTunnelA::Tunnel(TunnelId::new(r)))
|
||||
}
|
||||
veilid_capnp::operation_cancel_tunnel_a::Which::Error(r) => {
|
||||
let tunnel_error = decode_tunnel_error(r.map_err(RPCError::protocol)?);
|
||||
@@ -49,7 +49,7 @@ impl RPCOperationCancelTunnelA {
|
||||
) -> Result<(), RPCError> {
|
||||
match self {
|
||||
RPCOperationCancelTunnelA::Tunnel(p) => {
|
||||
builder.set_tunnel(*p);
|
||||
builder.set_tunnel(p.as_u64());
|
||||
}
|
||||
RPCOperationCancelTunnelA::Error(e) => {
|
||||
builder.set_error(encode_tunnel_error(*e));
|
||||
|
@@ -12,7 +12,7 @@ impl RPCOperationCompleteTunnelQ {
|
||||
pub fn decode(
|
||||
reader: &veilid_capnp::operation_complete_tunnel_q::Reader,
|
||||
) -> Result<RPCOperationCompleteTunnelQ, RPCError> {
|
||||
let id = reader.get_id();
|
||||
let id = TunnelId::new(reader.get_id());
|
||||
let local_mode = match reader.get_local_mode().map_err(RPCError::protocol)? {
|
||||
veilid_capnp::TunnelEndpointMode::Raw => TunnelMode::Raw,
|
||||
veilid_capnp::TunnelEndpointMode::Turn => TunnelMode::Turn,
|
||||
@@ -32,7 +32,7 @@ impl RPCOperationCompleteTunnelQ {
|
||||
&self,
|
||||
builder: &mut veilid_capnp::operation_complete_tunnel_q::Builder,
|
||||
) -> Result<(), RPCError> {
|
||||
builder.set_id(self.id);
|
||||
builder.set_id(self.id.as_u64());
|
||||
builder.set_local_mode(match self.local_mode {
|
||||
TunnelMode::Raw => veilid_capnp::TunnelEndpointMode::Raw,
|
||||
TunnelMode::Turn => veilid_capnp::TunnelEndpointMode::Turn,
|
||||
|
@@ -11,7 +11,7 @@ impl RPCOperationStartTunnelQ {
|
||||
pub fn decode(
|
||||
reader: &veilid_capnp::operation_start_tunnel_q::Reader,
|
||||
) -> Result<RPCOperationStartTunnelQ, RPCError> {
|
||||
let id = reader.get_id();
|
||||
let id = TunnelId::new(reader.get_id());
|
||||
let local_mode = match reader.get_local_mode().map_err(RPCError::protocol)? {
|
||||
veilid_capnp::TunnelEndpointMode::Raw => TunnelMode::Raw,
|
||||
veilid_capnp::TunnelEndpointMode::Turn => TunnelMode::Turn,
|
||||
@@ -28,7 +28,7 @@ impl RPCOperationStartTunnelQ {
|
||||
&self,
|
||||
builder: &mut veilid_capnp::operation_start_tunnel_q::Builder,
|
||||
) -> Result<(), RPCError> {
|
||||
builder.set_id(self.id);
|
||||
builder.set_id(self.id.as_u64());
|
||||
builder.set_local_mode(match self.local_mode {
|
||||
TunnelMode::Raw => veilid_capnp::TunnelEndpointMode::Raw,
|
||||
TunnelMode::Turn => veilid_capnp::TunnelEndpointMode::Turn,
|
||||
|
@@ -58,8 +58,8 @@ pub fn encode_full_tunnel(
|
||||
full_tunnel: &FullTunnel,
|
||||
builder: &mut veilid_capnp::full_tunnel::Builder,
|
||||
) -> Result<(), RPCError> {
|
||||
builder.set_id(full_tunnel.id);
|
||||
builder.set_timeout(full_tunnel.timeout);
|
||||
builder.set_id(full_tunnel.id.as_u64());
|
||||
builder.set_timeout(full_tunnel.timeout.as_u64());
|
||||
let mut l_builder = builder.reborrow().init_local();
|
||||
encode_tunnel_endpoint(&full_tunnel.local, &mut l_builder)?;
|
||||
let mut r_builder = builder.reborrow().init_remote();
|
||||
@@ -70,8 +70,8 @@ pub fn encode_full_tunnel(
|
||||
pub fn decode_full_tunnel(
|
||||
reader: &veilid_capnp::full_tunnel::Reader,
|
||||
) -> Result<FullTunnel, RPCError> {
|
||||
let id = reader.get_id();
|
||||
let timeout = reader.get_timeout();
|
||||
let id = TunnelId::new(reader.get_id());
|
||||
let timeout = TimestampDuration::new(reader.get_timeout());
|
||||
let l_reader = reader.get_local().map_err(RPCError::protocol)?;
|
||||
let local = decode_tunnel_endpoint(&l_reader)?;
|
||||
let r_reader = reader.get_remote().map_err(RPCError::protocol)?;
|
||||
@@ -89,8 +89,8 @@ pub fn encode_partial_tunnel(
|
||||
partial_tunnel: &PartialTunnel,
|
||||
builder: &mut veilid_capnp::partial_tunnel::Builder,
|
||||
) -> Result<(), RPCError> {
|
||||
builder.set_id(partial_tunnel.id);
|
||||
builder.set_timeout(partial_tunnel.timeout);
|
||||
builder.set_id(partial_tunnel.id.as_u64());
|
||||
builder.set_timeout(partial_tunnel.timeout.as_u64());
|
||||
let mut l_builder = builder.reborrow().init_local();
|
||||
encode_tunnel_endpoint(&partial_tunnel.local, &mut l_builder)?;
|
||||
Ok(())
|
||||
@@ -99,8 +99,8 @@ pub fn encode_partial_tunnel(
|
||||
pub fn decode_partial_tunnel(
|
||||
reader: &veilid_capnp::partial_tunnel::Reader,
|
||||
) -> Result<PartialTunnel, RPCError> {
|
||||
let id = reader.get_id();
|
||||
let timeout = reader.get_timeout();
|
||||
let id = TunnelId::new(reader.get_id());
|
||||
let timeout = TimestampDuration::new(reader.get_timeout());
|
||||
let l_reader = reader.get_local().map_err(RPCError::protocol)?;
|
||||
let local = decode_tunnel_endpoint(&l_reader)?;
|
||||
|
||||
|
@@ -254,7 +254,7 @@ impl RPCProcessor {
|
||||
// set up channel
|
||||
let mut concurrency = c.network.rpc.concurrency;
|
||||
let queue_size = c.network.rpc.queue_size;
|
||||
let timeout = ms_to_us(c.network.rpc.timeout_ms);
|
||||
let timeout_us = TimestampDuration::new(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 = get_concurrency() / 2;
|
||||
@@ -265,7 +265,7 @@ impl RPCProcessor {
|
||||
let validate_dial_info_receipt_time_ms = c.network.dht.validate_dial_info_receipt_time_ms;
|
||||
|
||||
RPCProcessorUnlockedInner {
|
||||
timeout_us: timeout,
|
||||
timeout_us,
|
||||
queue_size,
|
||||
concurrency,
|
||||
max_route_hop_count,
|
||||
@@ -879,8 +879,8 @@ impl RPCProcessor {
|
||||
let rss = self.routing_table.route_spec_store();
|
||||
|
||||
// Get latency for all local routes
|
||||
let mut total_local_latency = 0u64;
|
||||
let total_latency = recv_ts.saturating_sub(send_ts);
|
||||
let mut total_local_latency = TimestampDuration::new(0u64);
|
||||
let total_latency: TimestampDuration = recv_ts.saturating_sub(send_ts);
|
||||
|
||||
// If safety route was used, record route there
|
||||
if let Some(sr_pubkey) = &safety_route {
|
||||
@@ -932,12 +932,12 @@ impl RPCProcessor {
|
||||
if let Some(sr_pubkey) = &safety_route {
|
||||
let rss = self.routing_table.route_spec_store();
|
||||
rss.with_route_stats(send_ts, sr_pubkey, |s| {
|
||||
s.record_latency(total_latency / 2);
|
||||
s.record_latency(total_latency / 2u64);
|
||||
});
|
||||
}
|
||||
if let Some(pr_pubkey) = &reply_private_route {
|
||||
rss.with_route_stats(send_ts, pr_pubkey, |s| {
|
||||
s.record_latency(total_latency / 2);
|
||||
s.record_latency(total_latency / 2u64);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1365,7 +1365,7 @@ impl RPCProcessor {
|
||||
routing_domain,
|
||||
}),
|
||||
timestamp: get_aligned_timestamp(),
|
||||
body_len: body.len() as u64,
|
||||
body_len: ByteCount::new(body.len() as u64),
|
||||
},
|
||||
data: RPCMessageData { contents: body },
|
||||
};
|
||||
|
Reference in New Issue
Block a user