reth_network_types::peers::config

Struct PeersConfig

Source
pub struct PeersConfig {
    pub refill_slots_interval: Duration,
    pub trusted_nodes: Vec<TrustedPeer>,
    pub trusted_nodes_only: bool,
    pub max_backoff_count: u8,
    pub basic_nodes: HashSet<NodeRecord>,
    pub ban_duration: Duration,
    pub ban_list: BanList,
    pub connection_info: ConnectionsConfig,
    pub reputation_weights: ReputationChangeWeights,
    pub backoff_durations: PeerBackoffDurations,
    pub incoming_ip_throttle_duration: Duration,
}
Expand description

Config type for initiating a PeersManager instance.

Fields§

§refill_slots_interval: Duration

How often to recheck free slots for outbound connections.

§trusted_nodes: Vec<TrustedPeer>

Trusted nodes to connect to or accept from

§trusted_nodes_only: bool

Connect to or accept from trusted nodes only?

§max_backoff_count: u8

Maximum number of backoff attempts before we give up on a peer and dropping.

The max time spent of a peer before it’s removed from the set is determined by the configured backoff duration and the max backoff count.

With a backoff counter of 5 and a backoff duration of 1h, the minimum time spent of the peer in the table is the sum of all backoffs (1h + 2h + 3h + 4h + 5h = 15h).

Note: this does not apply to trusted peers.

§basic_nodes: HashSet<NodeRecord>

Basic nodes to connect to.

§ban_duration: Duration

How long to ban bad peers.

§ban_list: BanList

Restrictions on PeerIds and Ips.

§connection_info: ConnectionsConfig

Restrictions on connections.

§reputation_weights: ReputationChangeWeights

How to weigh reputation changes.

§backoff_durations: PeerBackoffDurations

How long to backoff peers that we are failed to connect to for non-fatal reasons.

The backoff duration increases with number of backoff attempts.

§incoming_ip_throttle_duration: Duration

How long to temporarily ban ips on incoming connection attempts.

This acts as an IP based rate limit.

Implementations§

Source§

impl PeersConfig

Source

pub fn with_ban_list(self, ban_list: BanList) -> Self

A set of peer_ids and ip addr that we want to never connect to

Source

pub const fn with_ban_duration(self, ban_duration: Duration) -> Self

Configure how long to ban bad peers

Source

pub const fn with_max_outbound(self, max_outbound: usize) -> Self

Maximum allowed outbound connections.

Source

pub const fn with_max_inbound_opt(self, max_inbound: Option<usize>) -> Self

Maximum allowed inbound connections with optional update.

Source

pub const fn with_max_outbound_opt(self, max_outbound: Option<usize>) -> Self

Maximum allowed outbound connections with optional update.

Source

pub const fn with_max_inbound(self, max_inbound: usize) -> Self

Maximum allowed inbound connections.

Source

pub const fn with_max_concurrent_dials( self, max_concurrent_outbound_dials: usize, ) -> Self

Maximum allowed concurrent outbound dials.

Source

pub fn with_trusted_nodes(self, nodes: Vec<TrustedPeer>) -> Self

Nodes to always connect to.

Source

pub const fn with_trusted_nodes_only(self, trusted_only: bool) -> Self

Connect only to trusted nodes.

Source

pub fn with_basic_nodes(self, nodes: HashSet<NodeRecord>) -> Self

Nodes available at launch.

Source

pub const fn with_max_backoff_count(self, max_backoff_count: u8) -> Self

Configures the max allowed backoff count.

Source

pub const fn with_reputation_weights( self, reputation_weights: ReputationChangeWeights, ) -> Self

Configures how to weigh reputation changes.

Source

pub const fn with_backoff_durations( self, backoff_durations: PeerBackoffDurations, ) -> Self

Configures how long to backoff peers that are we failed to connect to for non-fatal reasons

Source

pub const fn max_peers(&self) -> usize

Returns the maximum number of peers, inbound and outbound.

Source

pub fn with_basic_nodes_from_file( self, optional_file: Option<impl AsRef<Path>>, ) -> Result<Self, Error>

Read from file nodes available at launch. Ignored if None.

Source

pub fn test() -> Self

Available on crate feature test-utils only.

Returns settings for testing

Trait Implementations§

Source§

impl Clone for PeersConfig

Source§

fn clone(&self) -> PeersConfig

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PeersConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PeersConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PeersConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PeersConfig

Source§

fn eq(&self, other: &PeersConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PeersConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for PeersConfig

Source§

impl StructuralPartialEq for PeersConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 344 bytes