Struct libp2p_gossipsub::Gossipsub [−][src]
Network behaviour that handles the gossipsub protocol.
Implementations
impl Gossipsub
[src]
pub fn new(local_peer_id: PeerId, gs_config: GossipsubConfig) -> Self
[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]
&mut self,
topic: impl IntoIterator<Item = Topic>,
data: impl Into<Vec<u8>>
)
Publishes a message with multiple topics to the network.
pub fn propagate_message(
&mut self,
message_id: &MessageId,
propagation_source: &PeerId
) -> bool
[src]
&mut self,
message_id: &MessageId,
propagation_source: &PeerId
) -> bool
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 Debug for Gossipsub
[src]
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.
fn new_handler(&mut self) -> Self::ProtocolsHandler
[src]
fn addresses_of_peer(&mut self, _: &PeerId) -> Vec<Multiaddr>
[src]
fn inject_connected(&mut self, id: &PeerId)
[src]
fn inject_disconnected(&mut self, id: &PeerId)
[src]
fn inject_event(
&mut self,
propagation_source: PeerId,
_: ConnectionId,
event: GossipsubRpc
)
[src]
&mut self,
propagation_source: PeerId,
_: ConnectionId,
event: GossipsubRpc
)
fn poll(
&mut self,
cx: &mut Context<'_>,
_: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Self::ProtocolsHandler as ProtocolsHandler>::InEvent, Self::OutEvent>>
[src]
&mut self,
cx: &mut Context<'_>,
_: &mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<Self::ProtocolsHandler as ProtocolsHandler>::InEvent, Self::OutEvent>>
pub fn inject_connection_established(
&mut self,
&PeerId,
&ConnectionId,
&ConnectedPoint
)
[src]
&mut self,
&PeerId,
&ConnectionId,
&ConnectedPoint
)
pub fn inject_connection_closed(
&mut self,
&PeerId,
&ConnectionId,
&ConnectedPoint
)
[src]
&mut self,
&PeerId,
&ConnectionId,
&ConnectedPoint
)
pub fn inject_address_change(
&mut self,
&PeerId,
&ConnectionId,
_old: &ConnectedPoint,
_new: &ConnectedPoint
)
[src]
&mut self,
&PeerId,
&ConnectionId,
_old: &ConnectedPoint,
_new: &ConnectedPoint
)
pub fn inject_addr_reach_failure(
&mut self,
_peer_id: Option<&PeerId>,
_addr: &Multiaddr,
_error: &dyn Error
)
[src]
&mut self,
_peer_id: Option<&PeerId>,
_addr: &Multiaddr,
_error: &dyn Error
)
pub fn inject_dial_failure(&mut self, _peer_id: &PeerId)
[src]
pub fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)
[src]
pub fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)
[src]
pub fn inject_new_external_addr(&mut self, _addr: &Multiaddr)
[src]
pub fn inject_listener_error(
&mut self,
_id: ListenerId,
_err: &(dyn Error + 'static)
)
[src]
&mut self,
_id: ListenerId,
_err: &(dyn Error + 'static)
)
pub fn inject_listener_closed(
&mut self,
_id: ListenerId,
_reason: Result<(), &Error>
)
[src]
&mut self,
_id: ListenerId,
_reason: Result<(), &Error>
)
Auto Trait Implementations
impl !RefUnwindSafe for Gossipsub
[src]
impl Send for Gossipsub
[src]
impl Sync for Gossipsub
[src]
impl Unpin for Gossipsub
[src]
impl !UnwindSafe for Gossipsub
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,