Struct libp2p::gossipsub::GossipsubConfig[][src]

pub struct GossipsubConfig { /* fields omitted */ }
Expand description

Configuration parameters that define the performance of the gossipsub network.

Implementations

The protocol id prefix to negotiate this protocol. The protocol id is of the form /<prefix>/<supported-versions>. As gossipsub supports version 1.0 and 1.1, there are two protocol id’s supported.

The default prefix is meshsub, giving the supported protocol ids: /meshsub/1.1.0 and /meshsub/1.0.0, negotiated in that order.

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

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

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

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

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

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).

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

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.

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

Time between each heartbeat (default is 1 second).

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

The number of heartbeat ticks until we recheck the connection to explicit peers and reconnecting if necessary (default 300).

The maximum byte size for each gossipsub RPC (default is 65536 bytes).

This represents the maximum size of the entire protobuf payload. 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.

The time a connection is maintained to a peer without being in the mesh and without send/receiving a message from. Connections that idle beyond this timeout are disconnected. Default is 120 seconds.

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.

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::Gossipsub::report_message_validation_result() on the behaviour to forward message once validated (default is false). The default is false.

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

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.

A user-defined optional function that computes fast ids from raw messages. This can be used to avoid possibly expensive transformations from RawGossipsubMessage to GossipsubMessage for duplicates. Two semantically different messages must always have different fast message ids, but it is allowed that two semantically identical messages have different fast message ids as long as the message_id_fn produces the same id for them.

The function takes a RawGossipsubMessage as input and outputs a String to be interpreted as the fast message id. Default is None.

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.

Whether Peer eXchange is enabled; this should be enabled in bootstrappers and other well connected/trusted nodes. The default is true.

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.

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.

Number of heartbeat slots considered as slack for backoffs. This gurantees that we wait at least backoff_slack heartbeats after a backoff is over before we try to graft. This solves problems occuring 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.

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.

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.

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.

Number of heartbeat ticks that specifcy 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.

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.

The maximum number of new peers to graft to during opportunistic grafting. The default is 2.

The maximum number of messages we will process in a given RPC. If this is unset, there is no limit. The default is None.

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.

GossipSubMaxIHaveMessages is the maximum number of IHAVE messages to accept from a peer within a heartbeat.

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.

Enable support for flooodsub peers. Default false.

Published message ids time cache duration. The default is 10 seconds.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.