[][src]Struct libp2p::gossipsub::Gossipsub

pub struct Gossipsub { /* fields omitted */ }

Network behaviour that handles the gossipsub protocol.

Methods

impl Gossipsub[src]

pub fn new(local_peer_id: PeerId, gs_config: GossipsubConfig) -> Gossipsub[src]

Creates a Gossipsub struct given a set of parameters specified by gs_config.

pub fn subscribe(&mut self, topic: Topic) -> bool[src]

Subscribe to a topic.

Returns true if the subscription worked. Returns false if we were already subscribed.

pub fn unsubscribe(&mut self, topic: Topic) -> bool[src]

Unsubscribes from a topic.

Returns true if we were subscribed to this topic.

pub fn publish(&mut self, topic: &Topic, data: impl Into<Vec<u8>>)[src]

Publishes a message to the network.

pub fn publish_many(
    &mut self,
    topic: impl IntoIterator<Item = Topic>,
    data: impl Into<Vec<u8>>
)
[src]

Publishes a message with multiple topics to the network.

pub fn propagate_message(
    &mut self,
    message_id: &MessageId,
    propagation_source: &PeerId
) -> bool
[src]

This function should be called when config.manual_propagation is true in order to propagate messages. Messages are stored in the ['Memcache'] and validation is expected to be fast enough that the messages should still exist in the cache.

Calling this function will propagate a message stored in the cache, if it still exists. If the message still exists in the cache, it will be forwarded and this function will return true, otherwise it will return false.

Trait Implementations

impl NetworkBehaviour for Gossipsub[src]

type ProtocolsHandler = GossipsubHandler

Handler for all the protocols the network behaviour supports.

type OutEvent = GossipsubEvent

Event generated by the NetworkBehaviour and that the swarm will report back.

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>,