Struct libp2p::gossipsub::Gossipsub [−][src]
Network behaviour that handles the gossipsub protocol.
NOTE: Initialisation requires a MessageAuthenticity
and GossipsubConfig
instance. If message signing is
disabled, the ValidationMode
in the config should be adjusted to an appropriate level to
accept unsigned messages.
Implementations
impl Gossipsub
[src]
pub fn new(privacy: MessageAuthenticity, config: GossipsubConfig) -> Gossipsub
[src]
Creates a Gossipsub
struct given a set of parameters specified via a GossipsubConfig
.
pub fn topics(&self) -> impl Iterator<Item = &TopicHash>
[src]
Lists the hashes of the topics we are currently subscribed to.
pub fn peers(&self, topic_hash: &TopicHash) -> impl Iterator<Item = &PeerId>
[src]
Lists peers for a certain topic hash.
pub fn all_peers(&self) -> impl Iterator<Item = &PeerId>
[src]
Lists all peers for any topic.
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, Global>>
) -> Result<(), PublishError>
[src]
&mut self,
topic: &Topic,
data: impl Into<Vec<u8, Global>>
) -> Result<(), PublishError>
Publishes a message to the network.
pub fn publish_many(
&mut self,
topics: impl IntoIterator<Item = Topic>,
data: impl Into<Vec<u8, Global>>
) -> Result<(), PublishError>
[src]
&mut self,
topics: impl IntoIterator<Item = Topic>,
data: impl Into<Vec<u8, Global>>
) -> Result<(), PublishError>
Publishes a message with multiple topics to the network.
pub fn validate_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.validate_messages
is true
in order to
validate and 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.
The propagation_source
parameter indicates who the message was received by and will not
be forwarded back to that peer.
This should only be called once per message.
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.
pub fn new_handler(
&mut self
) -> <Gossipsub as NetworkBehaviour>::ProtocolsHandler
[src]
&mut self
) -> <Gossipsub as NetworkBehaviour>::ProtocolsHandler
pub fn addresses_of_peer(&mut self, &PeerId) -> Vec<Multiaddr, Global>
[src]
pub fn inject_connected(&mut self, id: &PeerId)
[src]
pub fn inject_disconnected(&mut self, id: &PeerId)
[src]
pub fn inject_event(
&mut self,
propagation_source: PeerId,
ConnectionId,
event: GossipsubRpc
)
[src]
&mut self,
propagation_source: PeerId,
ConnectionId,
event: GossipsubRpc
)
pub fn poll(
&mut self,
cx: &mut Context<'_>,
&mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<<Gossipsub as NetworkBehaviour>::ProtocolsHandler as ProtocolsHandler>::InEvent, <Gossipsub as NetworkBehaviour>::OutEvent>>
[src]
&mut self,
cx: &mut Context<'_>,
&mut impl PollParameters
) -> Poll<NetworkBehaviourAction<<<Gossipsub as NetworkBehaviour>::ProtocolsHandler as ProtocolsHandler>::InEvent, <Gossipsub as NetworkBehaviour>::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
impl Send for Gossipsub
impl Sync for Gossipsub
impl Unpin for Gossipsub
impl !UnwindSafe for Gossipsub
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
[src]
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>,
[src]
V: MultiLane<T>,