Skip to main content

reth_network_types/peers/
kind.rs

1//! Classification of a peer based on trust.
2
3/// Represents the kind of peer
4#[derive(Debug, Clone, Copy, Default, Eq, PartialEq)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[cfg_attr(feature = "serde", serde(rename_all = "lowercase"))]
7pub enum PeerKind {
8    /// Basic peer kind.
9    #[default]
10    Basic,
11    /// Static peer, added via JSON-RPC.
12    Static,
13    /// Trusted peer.
14    Trusted,
15}
16
17impl PeerKind {
18    /// Returns `true` if the peer is trusted.
19    pub const fn is_trusted(&self) -> bool {
20        matches!(self, Self::Trusted)
21    }
22
23    /// Returns `true` if the peer is static.
24    pub const fn is_static(&self) -> bool {
25        matches!(self, Self::Static)
26    }
27
28    /// Returns `true` if the peer is basic.
29    pub const fn is_basic(&self) -> bool {
30        matches!(self, Self::Basic)
31    }
32}