pub struct GossipSubManager { /* private fields */ }Expand description
GossipSub manager
Implementations§
Source§impl GossipSubManager
impl GossipSubManager
Sourcepub fn new(config: GossipSubConfig) -> Self
pub fn new(config: GossipSubConfig) -> Self
Create a new GossipSub manager
Sourcepub fn unsubscribe(&self, topic: &TopicId) -> Result<(), GossipSubError>
pub fn unsubscribe(&self, topic: &TopicId) -> Result<(), GossipSubError>
Unsubscribe from a topic
Sourcepub fn publish(
&self,
topic: TopicId,
data: Vec<u8>,
source: PeerId,
) -> Result<MessageId, GossipSubError>
pub fn publish( &self, topic: TopicId, data: Vec<u8>, source: PeerId, ) -> Result<MessageId, GossipSubError>
Publish a message to a topic
Sourcepub fn handle_message(
&self,
message: GossipSubMessage,
) -> Result<bool, GossipSubError>
pub fn handle_message( &self, message: GossipSubMessage, ) -> Result<bool, GossipSubError>
Handle received message
Sourcepub fn add_peer_to_mesh(
&self,
topic: &TopicId,
peer: PeerId,
) -> Result<(), GossipSubError>
pub fn add_peer_to_mesh( &self, topic: &TopicId, peer: PeerId, ) -> Result<(), GossipSubError>
Add peer to topic mesh
Sourcepub fn remove_peer_from_mesh(
&self,
topic: &TopicId,
peer: &PeerId,
) -> Result<(), GossipSubError>
pub fn remove_peer_from_mesh( &self, topic: &TopicId, peer: &PeerId, ) -> Result<(), GossipSubError>
Remove peer from topic mesh
Sourcepub fn get_mesh_peers(
&self,
topic: &TopicId,
) -> Result<Vec<PeerId>, GossipSubError>
pub fn get_mesh_peers( &self, topic: &TopicId, ) -> Result<Vec<PeerId>, GossipSubError>
Get peers in topic mesh
Sourcepub fn get_peer_score(&self, peer: &PeerId) -> Option<PeerScore>
pub fn get_peer_score(&self, peer: &PeerId) -> Option<PeerScore>
Get peer score
Sourcepub fn update_peer_score(&self, peer: &PeerId, topic: TopicId, score: f64)
pub fn update_peer_score(&self, peer: &PeerId, topic: TopicId, score: f64)
Update peer score for a topic
Sourcepub fn get_peers_to_prune(&self, topic: &TopicId, threshold: f64) -> Vec<PeerId>
pub fn get_peers_to_prune(&self, topic: &TopicId, threshold: f64) -> Vec<PeerId>
Get low-scoring peers that should be pruned
Sourcepub fn stats(&self) -> GossipSubStats
pub fn stats(&self) -> GossipSubStats
Get statistics
Sourcepub fn list_topics(&self) -> Vec<TopicId>
pub fn list_topics(&self) -> Vec<TopicId>
List subscribed topics
Sourcepub fn is_subscribed(&self, topic: &TopicId) -> bool
pub fn is_subscribed(&self, topic: &TopicId) -> bool
Check if subscribed to a topic
Auto Trait Implementations§
impl Freeze for GossipSubManager
impl !RefUnwindSafe for GossipSubManager
impl Send for GossipSubManager
impl Sync for GossipSubManager
impl Unpin for GossipSubManager
impl !UnwindSafe for GossipSubManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more