fixes for stats and crash
This commit is contained in:
@@ -351,6 +351,12 @@ impl NetworkManager {
|
||||
self.send_network_update();
|
||||
}
|
||||
|
||||
// Run the rolling transfers task
|
||||
self.unlocked_inner.rolling_transfers_task.tick().await?;
|
||||
|
||||
// Run the relay management task
|
||||
self.unlocked_inner.relay_management_task.tick().await?;
|
||||
|
||||
// Run the routing table tick
|
||||
routing_table.tick().await?;
|
||||
|
||||
|
@@ -10,7 +10,7 @@ const ROLLING_LATENCIES_SIZE: usize = 10;
|
||||
// - Size is number of entries
|
||||
// - Interval is number of seconds in each entry
|
||||
const ROLLING_TRANSFERS_SIZE: usize = 10;
|
||||
pub const ROLLING_TRANSFERS_INTERVAL_SECS: u32 = 10;
|
||||
pub const ROLLING_TRANSFERS_INTERVAL_SECS: u32 = 1;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub struct TransferCount {
|
||||
@@ -71,7 +71,7 @@ impl TransferStatsAccounting {
|
||||
transfer_stats.down.minimum.min_assign(bpsd);
|
||||
transfer_stats.up.minimum.min_assign(bpsu);
|
||||
transfer_stats.down.average += bpsd;
|
||||
transfer_stats.down.average += bpsu;
|
||||
transfer_stats.up.average += bpsu;
|
||||
}
|
||||
let len = self.rolling_transfers.len() as u64;
|
||||
transfer_stats.down.average /= len;
|
||||
|
@@ -3,7 +3,7 @@ use super::*;
|
||||
#[derive(Debug, Clone, PartialOrd, PartialEq, Eq, Ord)]
|
||||
pub enum RPCError {
|
||||
Timeout,
|
||||
InvalidFormat,
|
||||
InvalidFormat(String),
|
||||
Unreachable(DHTKey),
|
||||
Unimplemented(String),
|
||||
Protocol(String),
|
||||
@@ -14,6 +14,10 @@ pub fn rpc_error_internal<T: AsRef<str>>(x: T) -> RPCError {
|
||||
error!("RPCError Internal: {}", x.as_ref());
|
||||
RPCError::Internal(x.as_ref().to_owned())
|
||||
}
|
||||
pub fn rpc_error_invalid_format<T: AsRef<str>>(x: T) -> RPCError {
|
||||
error!("RPCError Invalid Format: {}", x.as_ref());
|
||||
RPCError::InvalidFormat(x.as_ref().to_owned())
|
||||
}
|
||||
pub fn rpc_error_protocol<T: AsRef<str>>(x: T) -> RPCError {
|
||||
error!("RPCError Protocol: {}", x.as_ref());
|
||||
RPCError::Protocol(x.as_ref().to_owned())
|
||||
@@ -35,7 +39,7 @@ impl fmt::Display for RPCError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
RPCError::Timeout => write!(f, "[RPCError: Timeout]"),
|
||||
RPCError::InvalidFormat => write!(f, "[RPCError: InvalidFormat]"),
|
||||
RPCError::InvalidFormat(s) => write!(f, "[RPCError: InvalidFormat({})]", s),
|
||||
RPCError::Unreachable(k) => write!(f, "[RPCError: Unreachable({})]", k),
|
||||
RPCError::Unimplemented(s) => write!(f, "[RPCError: Unimplemented({})]", s),
|
||||
RPCError::Protocol(s) => write!(f, "[RPCError: Protocol({})]", s),
|
||||
|
@@ -855,7 +855,9 @@ impl RPCProcessor {
|
||||
|
||||
// This should never want an answer
|
||||
if self.wants_answer(&operation)? {
|
||||
return Err(RPCError::InvalidFormat);
|
||||
return Err(rpc_error_invalid_format(
|
||||
"validate dial info should not want answer",
|
||||
));
|
||||
}
|
||||
|
||||
// get validateDialInfo reader
|
||||
@@ -958,7 +960,7 @@ impl RPCProcessor {
|
||||
|
||||
// find_node must always want an answer
|
||||
if !self.wants_answer(&operation)? {
|
||||
return Err(RPCError::InvalidFormat).map_err(logthru_rpc!());
|
||||
return Err(rpc_error_invalid_format("find_node_q should want answer"));
|
||||
}
|
||||
|
||||
// get findNodeQ reader
|
||||
@@ -1030,7 +1032,9 @@ impl RPCProcessor {
|
||||
|
||||
// This should never want an answer
|
||||
if self.wants_answer(&operation)? {
|
||||
return Err(RPCError::InvalidFormat);
|
||||
return Err(rpc_error_invalid_format(
|
||||
"node_info_update should not want answer",
|
||||
));
|
||||
}
|
||||
|
||||
// get nodeInfoUpdate reader
|
||||
@@ -1048,7 +1052,9 @@ impl RPCProcessor {
|
||||
|
||||
// Update our routing table with signed node info
|
||||
if !self.filter_peer_scope(&signed_node_info.node_info) {
|
||||
return Err(RPCError::InvalidFormat);
|
||||
return Err(rpc_error_invalid_format(
|
||||
"node_info_update has invalid peer scope",
|
||||
));
|
||||
}
|
||||
let _ = self
|
||||
.routing_table()
|
||||
@@ -1092,7 +1098,7 @@ impl RPCProcessor {
|
||||
|
||||
// This should never want an answer
|
||||
if self.wants_answer(&operation)? {
|
||||
return Err(RPCError::InvalidFormat);
|
||||
return Err(rpc_error_invalid_format("signal should not want answer"));
|
||||
}
|
||||
|
||||
// get signal reader
|
||||
@@ -1123,7 +1129,9 @@ impl RPCProcessor {
|
||||
|
||||
// This should never want an answer
|
||||
if self.wants_answer(&operation)? {
|
||||
return Err(RPCError::InvalidFormat);
|
||||
return Err(rpc_error_invalid_format(
|
||||
"return receipt should not want answer",
|
||||
));
|
||||
}
|
||||
|
||||
// get returnReceipt reader
|
||||
@@ -1229,7 +1237,9 @@ impl RPCProcessor {
|
||||
{
|
||||
// Sender NodeInfo was specified, update our routing table with it
|
||||
if !self.filter_peer_scope(&sender_ni.node_info) {
|
||||
return Err(RPCError::InvalidFormat);
|
||||
return Err(rpc_error_invalid_format(
|
||||
"respond_to_sender_signed_node_info has invalid peer scope",
|
||||
));
|
||||
}
|
||||
let nr = self
|
||||
.routing_table()
|
||||
@@ -1630,7 +1640,9 @@ impl RPCProcessor {
|
||||
let peer_info = decode_peer_info(&p, true)?;
|
||||
|
||||
if !self.filter_peer_scope(&peer_info.signed_node_info.node_info) {
|
||||
return Err(RPCError::InvalidFormat);
|
||||
return Err(rpc_error_invalid_format(
|
||||
"find_node response has invalid peer scope",
|
||||
));
|
||||
}
|
||||
|
||||
peers.push(peer_info);
|
||||
|
@@ -123,8 +123,8 @@ fn convert_rpc_error(x: RPCError) -> VeilidAPIError {
|
||||
RPCError::Unimplemented(s) => VeilidAPIError::Unimplemented { message: s },
|
||||
RPCError::Internal(s) => VeilidAPIError::Internal { message: s },
|
||||
RPCError::Protocol(s) => VeilidAPIError::Internal { message: s },
|
||||
RPCError::InvalidFormat => VeilidAPIError::Internal {
|
||||
message: "Invalid packet format".to_owned(),
|
||||
RPCError::InvalidFormat(s) => VeilidAPIError::Internal {
|
||||
message: format!("Invalid RPC format: {}", s),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user