Struct sc_network::discovery::DiscoveryConfig
source · 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 Selfwhere
I: IntoIterator<Item = (PeerId, Multiaddr)>,
pub fn with_permanent_addresses<I>( &mut self, permanent_addresses: I ) -> &mut Selfwhere I: IntoIterator<Item = (PeerId, Multiaddr)>,
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 RefUnwindSafe for DiscoveryConfig
impl Send for DiscoveryConfig
impl Sync for DiscoveryConfig
impl Unpin for DiscoveryConfig
impl UnwindSafe for DiscoveryConfig
Blanket Implementations§
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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§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 Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.