Struct Config
pub struct Config { /* private fields */ }
gossipsub
only.Expand description
Configuration parameters that define the performance of the gossipsub network.
Implementations§
§impl Config
impl Config
pub fn history_length(&self) -> usize
pub fn history_length(&self) -> usize
Number of heartbeats to keep in the memcache
(default is 5).
pub fn history_gossip(&self) -> usize
pub fn history_gossip(&self) -> usize
Number of past heartbeats to gossip about (default is 3).
pub fn mesh_n(&self) -> usize
pub fn mesh_n(&self) -> usize
Target number of peers for the mesh network (D in the spec, default is 6).
pub fn mesh_n_low(&self) -> usize
pub fn mesh_n_low(&self) -> usize
Minimum number of peers in mesh network before adding more (D_lo in the spec, default is 5).
pub fn mesh_n_high(&self) -> usize
pub fn mesh_n_high(&self) -> usize
Maximum number of peers in mesh network before removing some (D_high in the spec, default is 12).
pub fn retain_scores(&self) -> usize
pub fn retain_scores(&self) -> usize
Affects how peers are selected when pruning a mesh due to over subscription.
At least retain_scores
of the retained peers will be high-scoring, while the remainder
are chosen randomly (D_score in the spec, default is 4).
pub fn gossip_lazy(&self) -> usize
pub fn gossip_lazy(&self) -> usize
Minimum number of peers to emit gossip to during a heartbeat (D_lazy in the spec, default is 6).
pub fn gossip_factor(&self) -> f64
pub fn gossip_factor(&self) -> f64
Affects how many peers we will emit gossip to at each heartbeat.
We will send gossip to gossip_factor * (total number of non-mesh peers)
, or
gossip_lazy
, whichever is greater. The default is 0.25.
pub fn heartbeat_initial_delay(&self) -> Duration
pub fn heartbeat_initial_delay(&self) -> Duration
Initial delay in each heartbeat (default is 5 seconds).
pub fn heartbeat_interval(&self) -> Duration
pub fn heartbeat_interval(&self) -> Duration
Time between each heartbeat (default is 1 second).
pub fn fanout_ttl(&self) -> Duration
pub fn fanout_ttl(&self) -> Duration
Time to live for fanout peers (default is 60 seconds).
pub fn check_explicit_peers_ticks(&self) -> u64
pub fn check_explicit_peers_ticks(&self) -> u64
The number of heartbeat ticks until we recheck the connection to explicit peers and reconnecting if necessary (default 300).
pub fn max_transmit_size(&self) -> usize
pub fn max_transmit_size(&self) -> usize
The maximum byte size for each gossipsub RPC (default is 65536 bytes).
This represents the maximum size of the published message. It is additionally wrapped in a protobuf struct, so the actual wire size may be a bit larger. It must be at least large enough to support basic control messages. If Peer eXchange is enabled, this must be large enough to transmit the desired peer information on pruning. It must be at least 100 bytes. Default is 65536 bytes.
pub fn duplicate_cache_time(&self) -> Duration
pub fn duplicate_cache_time(&self) -> Duration
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 validate_messages(&self) -> bool
pub fn validate_messages(&self) -> bool
When set to true
, prevents automatic forwarding of all received messages. This setting
allows a user to validate the messages before propagating them to their peers. If set to
true, the user must manually call crate::Behaviour::report_message_validation_result()
on the behaviour to forward message once validated (default is false
).
The default is false
.
pub fn validation_mode(&self) -> &ValidationMode
pub fn validation_mode(&self) -> &ValidationMode
Determines the level of validation used when receiving messages. See ValidationMode
for the available types. The default is ValidationMode::Strict.
pub fn message_id(&self, message: &Message) -> MessageId
pub fn message_id(&self, message: &Message) -> MessageId
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 Message
as input and outputs a String to be interpreted as
the message id.
pub fn allow_self_origin(&self) -> bool
pub fn allow_self_origin(&self) -> bool
By default, gossipsub will reject messages that are sent to us that have the same message source as we have specified locally. Enabling this, allows these messages and prevents penalizing the peer that sent us the message. Default is false.
pub fn do_px(&self) -> bool
pub fn do_px(&self) -> bool
Whether Peer eXchange is enabled; this should be enabled in bootstrappers and other well connected/trusted nodes. The default is false.
Note: Peer exchange is not implemented today, see https://github.com/libp2p/rust-libp2p/issues/2398.
pub fn prune_peers(&self) -> usize
pub fn prune_peers(&self) -> usize
Controls the number of peers to include in prune Peer eXchange.
When we prune a peer that’s eligible for PX (has a good score, etc), we will try to
send them signed peer records for up to prune_peers
other peers that we
know of. It is recommended that this value is larger than mesh_n_high
so that the pruned
peer can reliably form a full mesh. The default is typically 16 however until signed
records are spec’d this is disabled and set to 0.
pub fn prune_backoff(&self) -> Duration
pub fn prune_backoff(&self) -> Duration
Controls the backoff time for pruned peers. This is how long
a peer must wait before attempting to graft into our mesh again after being pruned.
When pruning a peer, we send them our value of prune_backoff
so they know
the minimum time to wait. Peers running older versions may not send a backoff time,
so if we receive a prune message without one, we will wait at least prune_backoff
before attempting to re-graft. The default is one minute.
pub fn unsubscribe_backoff(&self) -> Duration
pub fn unsubscribe_backoff(&self) -> Duration
Controls the backoff time when unsubscribing from a topic.
This is how long to wait before resubscribing to the topic. A short backoff period in case of an unsubscribe event allows reaching a healthy mesh in a more timely manner. The default is 10 seconds.
pub fn backoff_slack(&self) -> u32
pub fn backoff_slack(&self) -> u32
Number of heartbeat slots considered as slack for backoffs. This guarantees that we wait
at least backoff_slack heartbeats after a backoff is over before we try to graft. This
solves problems occurring through high latencies. In particular if
backoff_slack * heartbeat_interval
is longer than any latencies between processing
prunes on our side and processing prunes on the receiving side this guarantees that we
get not punished for too early grafting. The default is 1.
pub fn flood_publish(&self) -> bool
pub fn flood_publish(&self) -> bool
Whether to do flood publishing or not. If enabled newly created messages will always be sent to all peers that are subscribed to the topic and have a good enough score. The default is true.
pub fn graft_flood_threshold(&self) -> Duration
pub fn graft_flood_threshold(&self) -> Duration
If a GRAFT comes before graft_flood_threshold
has elapsed since the last PRUNE,
then there is an extra score penalty applied to the peer through P7.
pub fn mesh_outbound_min(&self) -> usize
pub fn mesh_outbound_min(&self) -> usize
Minimum number of outbound peers in the mesh network before adding more (D_out in the spec).
This value must be smaller or equal than mesh_n / 2
and smaller than mesh_n_low
.
The default is 2.
pub fn opportunistic_graft_ticks(&self) -> u64
pub fn opportunistic_graft_ticks(&self) -> u64
Number of heartbeat ticks that specify the interval in which opportunistic grafting is
applied. Every opportunistic_graft_ticks
we will attempt to select some high-scoring mesh
peers to replace lower-scoring ones, if the median score of our mesh peers falls below a
threshold (see https://godoc.org/github.com/libp2p/go-libp2p-pubsub#PeerScoreThresholds).
The default is 60.
pub fn gossip_retransimission(&self) -> u32
pub fn gossip_retransimission(&self) -> u32
Controls how many times we will allow a peer to request the same message id through IWANT gossip before we start ignoring them. This is designed to prevent peers from spamming us with requests and wasting our resources. The default is 3.
pub fn opportunistic_graft_peers(&self) -> usize
pub fn opportunistic_graft_peers(&self) -> usize
The maximum number of new peers to graft to during opportunistic grafting. The default is 2.
pub fn max_messages_per_rpc(&self) -> Option<usize>
pub fn max_messages_per_rpc(&self) -> Option<usize>
The maximum number of messages we will process in a given RPC. If this is unset, there is no limit. The default is None.
pub fn max_ihave_length(&self) -> usize
pub fn max_ihave_length(&self) -> usize
The maximum number of messages to include in an IHAVE message. Also controls the maximum number of IHAVE ids we will accept and request with IWANT from a peer within a heartbeat, to protect from IHAVE floods. You should adjust this value from the default if your system is pushing more than 5000 messages in GossipSubHistoryGossip heartbeats; with the defaults this is 1666 messages/s. The default is 5000.
pub fn max_ihave_messages(&self) -> usize
pub fn max_ihave_messages(&self) -> usize
GossipSubMaxIHaveMessages is the maximum number of IHAVE messages to accept from a peer within a heartbeat.
pub fn iwant_followup_time(&self) -> Duration
pub fn iwant_followup_time(&self) -> Duration
Time to wait for a message requested through IWANT following an IHAVE advertisement. If the message is not received within this window, a broken promise is declared and the router may apply behavioural penalties. The default is 3 seconds.
pub fn support_floodsub(&self) -> bool
pub fn support_floodsub(&self) -> bool
Enable support for flooodsub peers. Default false.
pub fn published_message_ids_cache_time(&self) -> Duration
pub fn published_message_ids_cache_time(&self) -> Duration
Published message ids time cache duration. The default is 10 seconds.
pub fn connection_handler_queue_len(&self) -> usize
pub fn connection_handler_queue_len(&self) -> usize
The max number of messages a ConnectionHandler
can buffer. The default is 5000.
pub fn publish_queue_duration(&self) -> Duration
pub fn publish_queue_duration(&self) -> Duration
The duration a message to be published can wait to be sent before it is abandoned. The default is 5 seconds.
pub fn forward_queue_duration(&self) -> Duration
pub fn forward_queue_duration(&self) -> Duration
The duration a message to be forwarded can wait to be sent before it is abandoned. The default is 1s.
Trait Implementations§
§impl From<Config> for ConfigBuilder
impl From<Config> for ConfigBuilder
§fn from(config: Config) -> ConfigBuilder
fn from(config: Config) -> ConfigBuilder
Auto Trait Implementations§
impl Freeze for Config
impl !RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl !UnwindSafe for Config
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more