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
impl PeersConfig
Sourcepub fn with_ban_list(self, ban_list: BanList) -> Self
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
Sourcepub const fn with_ban_duration(self, ban_duration: Duration) -> Self
pub const fn with_ban_duration(self, ban_duration: Duration) -> Self
Configure how long to ban bad peers
Sourcepub const fn with_max_outbound(self, max_outbound: usize) -> Self
pub const fn with_max_outbound(self, max_outbound: usize) -> Self
Maximum allowed outbound connections.
Sourcepub const fn with_max_inbound_opt(self, max_inbound: Option<usize>) -> Self
pub const fn with_max_inbound_opt(self, max_inbound: Option<usize>) -> Self
Maximum allowed inbound connections with optional update.
Sourcepub const fn with_max_outbound_opt(self, max_outbound: Option<usize>) -> Self
pub const fn with_max_outbound_opt(self, max_outbound: Option<usize>) -> Self
Maximum allowed outbound connections with optional update.
Sourcepub const fn with_max_inbound(self, max_inbound: usize) -> Self
pub const fn with_max_inbound(self, max_inbound: usize) -> Self
Maximum allowed inbound connections.
Sourcepub const fn with_max_concurrent_dials(
self,
max_concurrent_outbound_dials: usize,
) -> Self
pub const fn with_max_concurrent_dials( self, max_concurrent_outbound_dials: usize, ) -> Self
Maximum allowed concurrent outbound dials.
Sourcepub fn with_trusted_nodes(self, nodes: Vec<TrustedPeer>) -> Self
pub fn with_trusted_nodes(self, nodes: Vec<TrustedPeer>) -> Self
Nodes to always connect to.
Sourcepub const fn with_trusted_nodes_only(self, trusted_only: bool) -> Self
pub const fn with_trusted_nodes_only(self, trusted_only: bool) -> Self
Connect only to trusted nodes.
Sourcepub fn with_basic_nodes(self, nodes: HashSet<NodeRecord>) -> Self
pub fn with_basic_nodes(self, nodes: HashSet<NodeRecord>) -> Self
Nodes available at launch.
Sourcepub const fn with_max_backoff_count(self, max_backoff_count: u8) -> Self
pub const fn with_max_backoff_count(self, max_backoff_count: u8) -> Self
Configures the max allowed backoff count.
Sourcepub const fn with_reputation_weights(
self,
reputation_weights: ReputationChangeWeights,
) -> Self
pub const fn with_reputation_weights( self, reputation_weights: ReputationChangeWeights, ) -> Self
Configures how to weigh reputation changes.
Sourcepub const fn with_backoff_durations(
self,
backoff_durations: PeerBackoffDurations,
) -> Self
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
Sourcepub const fn max_peers(&self) -> usize
pub const fn max_peers(&self) -> usize
Returns the maximum number of peers, inbound and outbound.
Trait Implementations§
Source§impl Clone for PeersConfig
impl Clone for PeersConfig
Source§fn clone(&self) -> PeersConfig
fn clone(&self) -> PeersConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PeersConfig
impl Debug for PeersConfig
Source§impl Default for PeersConfig
impl Default for PeersConfig
Source§impl<'de> Deserialize<'de> for PeersConfigwhere
PeersConfig: Default,
impl<'de> Deserialize<'de> for PeersConfigwhere
PeersConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for PeersConfig
impl PartialEq for PeersConfig
Source§impl Serialize for PeersConfig
impl Serialize for PeersConfig
impl Eq for PeersConfig
impl StructuralPartialEq for PeersConfig
Auto Trait Implementations§
impl Freeze for PeersConfig
impl RefUnwindSafe for PeersConfig
impl Send for PeersConfig
impl Sync for PeersConfig
impl Unpin for PeersConfig
impl UnwindSafe for PeersConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
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