mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-02-20 11:48:35 -06:00
cleanup syntax
This commit is contained in:
parent
8aa5c8c5bb
commit
2a77d66cef
@ -723,20 +723,19 @@ impl BucketEntryInner {
|
|||||||
|
|
||||||
match self.peer_stats.rpc_stats.first_consecutive_seen_ts {
|
match self.peer_stats.rpc_stats.first_consecutive_seen_ts {
|
||||||
// If we have not seen seen a node consecutively, it can't be reliable
|
// If we have not seen seen a node consecutively, it can't be reliable
|
||||||
None => Some(BucketEntryUnreliableReason::NotSeenConsecutively),
|
None => return Some(BucketEntryUnreliableReason::NotSeenConsecutively),
|
||||||
// If we have seen the node consistently for longer than UNRELIABLE_PING_SPAN_SECS then it is reliable
|
// If not have seen the node consistently for longer than UNRELIABLE_PING_SPAN_SECS then it is unreliable
|
||||||
Some(ts) => {
|
Some(ts) => {
|
||||||
let seen_consecutively = cur_ts.saturating_sub(ts) >= TimestampDuration::new(UNRELIABLE_PING_SPAN_SECS as u64 * 1000000u64);
|
let seen_consecutively = cur_ts.saturating_sub(ts) >= TimestampDuration::new(UNRELIABLE_PING_SPAN_SECS as u64 * 1_000_000u64);
|
||||||
if seen_consecutively {
|
if !seen_consecutively {
|
||||||
None
|
return Some(BucketEntryUnreliableReason::InUnreliablePingSpan);
|
||||||
} else {
|
|
||||||
Some(BucketEntryUnreliableReason::InUnreliablePingSpan)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
None
|
||||||
}
|
}
|
||||||
pub(super) fn check_dead(&self, cur_ts: Timestamp) -> Option<BucketEntryDeadReason> {
|
pub(super) fn check_dead(&self, cur_ts: Timestamp) -> Option<BucketEntryDeadReason> {
|
||||||
|
|
||||||
// If we have failed to send NEVER_REACHED_PING_COUNT times in a row, the node is dead
|
// If we have failed to send NEVER_REACHED_PING_COUNT times in a row, the node is dead
|
||||||
if self.peer_stats.rpc_stats.failed_to_send >= NEVER_SEEN_PING_COUNT {
|
if self.peer_stats.rpc_stats.failed_to_send >= NEVER_SEEN_PING_COUNT {
|
||||||
return Some(BucketEntryDeadReason::FailedToSend);
|
return Some(BucketEntryDeadReason::FailedToSend);
|
||||||
@ -748,24 +747,22 @@ impl BucketEntryInner {
|
|||||||
None => {
|
None => {
|
||||||
let no_answers = self.peer_stats.rpc_stats.recent_lost_answers >= NEVER_SEEN_PING_COUNT;
|
let no_answers = self.peer_stats.rpc_stats.recent_lost_answers >= NEVER_SEEN_PING_COUNT;
|
||||||
if no_answers {
|
if no_answers {
|
||||||
Some(BucketEntryDeadReason::TooManyLostAnswers)
|
return Some(BucketEntryDeadReason::TooManyLostAnswers)
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return dead if we have not heard from the node at all for the duration of the unreliable ping span
|
// return dead if we have not heard from the node at all for the duration of the unreliable ping span
|
||||||
// and we have tried to reach it and failed the entire time of unreliable ping span
|
// and we have tried to reach it and failed the entire time of unreliable ping span
|
||||||
Some(ts) => {
|
Some(ts) => {
|
||||||
let not_seen = cur_ts.saturating_sub(ts) >= TimestampDuration::new(UNRELIABLE_PING_SPAN_SECS as u64 * 1000000u64);
|
let not_seen = cur_ts.saturating_sub(ts) >= TimestampDuration::new(UNRELIABLE_PING_SPAN_SECS as u64 * 1_000_000u64);
|
||||||
let no_answers = self.peer_stats.rpc_stats.recent_lost_answers >= (UNRELIABLE_PING_SPAN_SECS / UNRELIABLE_PING_INTERVAL_SECS);
|
let no_answers = self.peer_stats.rpc_stats.recent_lost_answers >= (UNRELIABLE_PING_SPAN_SECS / UNRELIABLE_PING_INTERVAL_SECS);
|
||||||
if not_seen && no_answers {
|
if not_seen && no_answers {
|
||||||
Some(BucketEntryDeadReason::NoPingResponse)
|
return Some(BucketEntryDeadReason::NoPingResponse)
|
||||||
} else {
|
}
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the last time we either saw a node, or asked it a question
|
/// Return the last time we either saw a node, or asked it a question
|
||||||
|
Loading…
Reference in New Issue
Block a user