reth_network_types/backoff.rs
1/// Describes the type of backoff should be applied.
2#[derive(Debug, Clone, PartialEq, Eq)]
3pub enum BackoffKind {
4 /// Use the lowest configured backoff duration.
5 ///
6 /// This applies to connection problems where there is a chance that they will be resolved
7 /// after the short duration.
8 Low,
9 /// Use a slightly higher duration to put a peer in timeout
10 ///
11 /// This applies to more severe connection problems where there is a lower chance that they
12 /// will be resolved.
13 Medium,
14 /// Use the max configured backoff duration.
15 ///
16 /// This is intended for spammers, or bad peers in general.
17 High,
18}
19
20// === impl BackoffKind ===
21
22impl BackoffKind {
23 /// Returns true if the backoff is considered severe.
24 pub const fn is_severe(&self) -> bool {
25 matches!(self, Self::Medium | Self::High)
26 }
27}