[][src]Struct libp2p::gossipsub::GossipsubConfigBuilder

pub struct GossipsubConfigBuilder { /* fields omitted */ }

The builder struct for constructing a gossipsub configuration.

Implementations

impl GossipsubConfigBuilder[src]

pub fn new() -> GossipsubConfigBuilder[src]

pub fn protocol_id(
    &mut self,
    protocol_id: impl Into<Cow<'static, [u8]>>
) -> &mut GossipsubConfigBuilder
[src]

The protocol id to negotiate this protocol (default is /meshsub/1.0.0).

pub fn history_length(
    &mut self,
    history_length: usize
) -> &mut GossipsubConfigBuilder
[src]

Number of heartbeats to keep in the memcache (default is 5).

pub fn history_gossip(
    &mut self,
    history_gossip: usize
) -> &mut GossipsubConfigBuilder
[src]

Number of past heartbeats to gossip about (default is 3).

pub fn mesh_n(&mut self, mesh_n: usize) -> &mut GossipsubConfigBuilder[src]

Target number of peers for the mesh network (D in the spec, default is 6).

pub fn mesh_n_low(&mut self, mesh_n_low: usize) -> &mut GossipsubConfigBuilder[src]

Minimum number of peers in mesh network before adding more (D_lo in the spec, default is 4).

pub fn mesh_n_high(&mut self, mesh_n_high: usize) -> &mut GossipsubConfigBuilder[src]

Maximum number of peers in mesh network before removing some (D_high in the spec, default is 12).

pub fn gossip_lazy(&mut self, gossip_lazy: usize) -> &mut GossipsubConfigBuilder[src]

Number of peers to emit gossip to during a heartbeat (D_lazy in the spec, default is 6).

pub fn heartbeat_initial_delay(
    &mut self,
    heartbeat_initial_delay: Duration
) -> &mut GossipsubConfigBuilder
[src]

Initial delay in each heartbeat (default is 5 seconds).

pub fn heartbeat_interval(
    &mut self,
    heartbeat_interval: Duration
) -> &mut GossipsubConfigBuilder
[src]

Time between each heartbeat (default is 1 second).

pub fn fanout_ttl(
    &mut self,
    fanout_ttl: Duration
) -> &mut GossipsubConfigBuilder
[src]

Time to live for fanout peers (default is 60 seconds).

pub fn max_transmit_size(
    &mut self,
    max_transmit_size: usize
) -> &mut GossipsubConfigBuilder
[src]

The maximum byte size for each gossip (default is 2048 bytes).

pub fn duplicate_cache_time(
    &mut self,
    cache_size: Duration
) -> &mut GossipsubConfigBuilder
[src]

Duplicates are prevented by storing message id's of known messages in an LRU time cache. This settings sets the time period that messages are stored in the cache. Duplicates can be received if duplicate messages are sent at a time greater than this setting apart. The default is 1 minute.

pub fn hash_topics(&mut self) -> &mut GossipsubConfigBuilder[src]

When set, gossipsub topics are hashed instead of being sent as plain strings.

pub fn validate_messages(&mut self) -> &mut GossipsubConfigBuilder[src]

When set, prevents automatic forwarding of all received messages. This setting allows a user to validate the messages before propagating them to their peers. If set, the user must manually call validate_message() on the behaviour to forward a message once validated.

pub fn validation_mode(
    &mut self,
    validation_mode: ValidationMode
) -> &mut GossipsubConfigBuilder
[src]

Determines the level of validation used when receiving messages. See ValidationMode for the available types. The default is ValidationMode::Strict.

pub fn message_id_fn(
    &mut self,
    id_fn: fn(&GossipsubMessage) -> MessageId
) -> &mut GossipsubConfigBuilder
[src]

A user-defined function allowing the user to specify the message id of a gossipsub message. The default value is to concatenate the source peer id with a sequence number. Setting this parameter allows the user to address packets arbitrarily. One example is content based addressing, where this function may be set to hash(message). This would prevent messages of the same content from being duplicated.

The function takes a GossipsubMessage as input and outputs a String to be interpreted as the message id.

pub fn build(&self) -> GossipsubConfig[src]

Constructs a GossipsubConfig from the given configuration.

Trait Implementations

impl Default for GossipsubConfigBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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