[−][src]Struct libp2p_gossipsub::Gossipsub
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) -> Self
[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>>
) -> Result<(), PublishError>
[src]
&mut self,
topic: &Topic,
data: impl Into<Vec<u8>>
) -> Result<(), PublishError>
Publishes a message to the network.
pub fn publish_many(
&mut self,
topics: impl IntoIterator<Item = Topic>,
data: impl Into<Vec<u8>>
) -> Result<(), PublishError>
[src]
&mut self,
topics: impl IntoIterator<Item = Topic>,
data: impl Into<Vec<u8>>
) -> 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.
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>>
fn inject_connection_established(
&mut self,
&PeerId,
&ConnectionId,
&ConnectedPoint
)
[src]
&mut self,
&PeerId,
&ConnectionId,
&ConnectedPoint
)
fn inject_connection_closed(&mut self, &PeerId, &ConnectionId, &ConnectedPoint)
[src]
fn inject_address_change(
&mut self,
&PeerId,
&ConnectionId,
_old: &ConnectedPoint,
_new: &ConnectedPoint
)
[src]
&mut self,
&PeerId,
&ConnectionId,
_old: &ConnectedPoint,
_new: &ConnectedPoint
)
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
)
fn inject_dial_failure(&mut self, _peer_id: &PeerId)
[src]
fn inject_new_listen_addr(&mut self, _addr: &Multiaddr)
[src]
fn inject_expired_listen_addr(&mut self, _addr: &Multiaddr)
[src]
fn inject_new_external_addr(&mut self, _addr: &Multiaddr)
[src]
fn inject_listener_error(
&mut self,
_id: ListenerId,
_err: &(dyn Error + 'static)
)
[src]
&mut self,
_id: ListenerId,
_err: &(dyn Error + 'static)
)
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,
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.
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.
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>,