pub struct DiscoveryConfig { /* private fields */ }
Expand description
DiscoveryBehaviour
configuration.
Note: In order to discover nodes or load and store values via Kademlia one has to add
Kademlia protocol via DiscoveryConfig::with_kademlia
.
Implementations§
Source§impl DiscoveryConfig
impl DiscoveryConfig
Sourcepub fn new(local_peer_id: PeerId) -> Self
pub fn new(local_peer_id: PeerId) -> Self
Create a default configuration with the given public key.
Sourcepub fn discovery_limit(&mut self, limit: u64) -> &mut Self
pub fn discovery_limit(&mut self, limit: u64) -> &mut Self
Set the number of active connections at which we pause discovery.
Sourcepub fn with_permanent_addresses<I>(
&mut self,
permanent_addresses: I,
) -> &mut Self
pub fn with_permanent_addresses<I>( &mut self, permanent_addresses: I, ) -> &mut Self
Set custom nodes which never expire, e.g. bootstrap or reserved nodes.
Sourcepub fn with_dht_random_walk(&mut self, value: bool) -> &mut Self
pub fn with_dht_random_walk(&mut self, value: bool) -> &mut Self
Whether the discovery behaviour should periodically perform a random walk on the DHT to discover peers.
Sourcepub fn allow_private_ip(&mut self, value: bool) -> &mut Self
pub fn allow_private_ip(&mut self, value: bool) -> &mut Self
Should private IPv4/IPv6 addresses be reported?
Sourcepub fn allow_non_globals_in_dht(&mut self, value: bool) -> &mut Self
pub fn allow_non_globals_in_dht(&mut self, value: bool) -> &mut Self
Should non-global addresses be inserted to the DHT?
Sourcepub fn with_kademlia<Hash: AsRef<[u8]>>(
&mut self,
genesis_hash: Hash,
fork_id: Option<&str>,
protocol_id: &ProtocolId,
) -> &mut Self
pub fn with_kademlia<Hash: AsRef<[u8]>>( &mut self, genesis_hash: Hash, fork_id: Option<&str>, protocol_id: &ProtocolId, ) -> &mut Self
Add discovery via Kademlia for the given protocol.
Currently accepts protocol_id
. This should be removed once all the nodes
are upgraded to genesis hash- and fork ID-based Kademlia protocol name.
Sourcepub fn use_kademlia_disjoint_query_paths(&mut self, value: bool) -> &mut Self
pub fn use_kademlia_disjoint_query_paths(&mut self, value: bool) -> &mut Self
Require iterative Kademlia DHT queries to use disjoint paths for increased resiliency in the presence of potentially adversarial nodes.
Sourcepub fn with_kademlia_replication_factor(
&mut self,
value: NonZeroUsize,
) -> &mut Self
pub fn with_kademlia_replication_factor( &mut self, value: NonZeroUsize, ) -> &mut Self
Sets Kademlia replication factor.
Sourcepub fn finish(self) -> DiscoveryBehaviour
pub fn finish(self) -> DiscoveryBehaviour
Create a DiscoveryBehaviour
from this config.
Auto Trait Implementations§
impl Freeze for DiscoveryConfig
impl RefUnwindSafe for DiscoveryConfig
impl Send for DiscoveryConfig
impl Sync for DiscoveryConfig
impl Unpin for DiscoveryConfig
impl UnwindSafe for DiscoveryConfig
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moreSource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.