reliability work

This commit is contained in:
John Smith
2023-06-24 11:16:34 -04:00
parent acebcb7947
commit 197b7fef6e
14 changed files with 191 additions and 84 deletions

View File

@@ -1122,6 +1122,7 @@ impl NetworkManager {
// or other firewalling issues and may perform better with TCP.
let unreliable = target_node_ref.peer_stats().rpc_stats.failed_to_send > 2 || target_node_ref.peer_stats().rpc_stats.recent_lost_answers > 2;
if unreliable && sequencing < Sequencing::PreferOrdered {
log_net!(debug "Node contact failing over to Ordered for {}", target_node_ref.to_string().cyan());
sequencing = Sequencing::PreferOrdered;
}

View File

@@ -491,13 +491,9 @@ impl DialInfo {
}
pub fn ordered_sequencing_sort(a: &DialInfo, b: &DialInfo) -> core::cmp::Ordering {
let ca = a.protocol_type().sort_order(Sequencing::EnsureOrdered);
let cb = b.protocol_type().sort_order(Sequencing::EnsureOrdered);
if ca < cb {
return core::cmp::Ordering::Less;
}
if ca > cb {
return core::cmp::Ordering::Greater;
let s = ProtocolType::ordered_sequencing_sort(a.protocol_type(), b.protocol_type());
if s != core::cmp::Ordering::Equal {
return s;
}
match (a, b) {
(DialInfo::UDP(a), DialInfo::UDP(b)) => a.cmp(b),

View File

@@ -61,6 +61,20 @@ impl DialInfoFilter {
pub fn is_dead(&self) -> bool {
self.protocol_type_set.is_empty() || self.address_type_set.is_empty()
}
pub fn with_sequencing(mut self, sequencing: Sequencing) -> (bool, DialInfoFilter) {
// Get first filtered dialinfo
match sequencing {
Sequencing::NoPreference => (false, self),
Sequencing::PreferOrdered => (true, self),
Sequencing::EnsureOrdered => (
true,
self.filtered(
&DialInfoFilter::all().with_protocol_type_set(ProtocolType::all_ordered_set()),
),
),
}
// return ordered sort and filter with ensure applied
}
}
impl fmt::Debug for DialInfoFilter {
@@ -80,7 +94,24 @@ impl fmt::Debug for DialInfoFilter {
}
}
impl From<ProtocolType> for DialInfoFilter {
fn from(other: ProtocolType) -> Self {
Self {
protocol_type_set: ProtocolTypeSet::from(other),
address_type_set: AddressTypeSet::all(),
}
}
}
impl From<AddressType> for DialInfoFilter {
fn from(other: AddressType) -> Self {
Self {
protocol_type_set: ProtocolTypeSet::all(),
address_type_set: AddressTypeSet::from(other),
}
}
}
pub trait MatchesDialInfoFilter {
fn matches_filter(&self, filter: &DialInfoFilter) -> bool;
}

View File

@@ -72,6 +72,18 @@ impl ProtocolType {
pub fn all_ordered_set() -> ProtocolTypeSet {
ProtocolType::TCP | ProtocolType::WS | ProtocolType::WSS
}
pub fn ordered_sequencing_sort(a: Self, b: Self) -> core::cmp::Ordering {
let ca = a.sort_order(Sequencing::EnsureOrdered);
let cb = b.sort_order(Sequencing::EnsureOrdered);
if ca < cb {
return core::cmp::Ordering::Less;
}
if ca > cb {
return core::cmp::Ordering::Greater;
}
core::cmp::Ordering::Equal
}
}
impl fmt::Display for ProtocolType {