Struct reth_network_types::peers::config::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,
}
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.

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 T)

🔬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 ()

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>,

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: 328 bytes