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
Source§impl GossipSubManager
impl GossipSubManager
Sourcepub fn subscribe_inference_topics(&self) -> Result<(), GossipSubError>
pub fn subscribe_inference_topics(&self) -> Result<(), GossipSubError>
Subscribe to all standard IPFRS inference topics
Sourcepub fn publish_inference_request(
&self,
request_bytes: &[u8],
sender_peer_id: &str,
) -> Result<(), GossipSubError>
pub fn publish_inference_request( &self, request_bytes: &[u8], sender_peer_id: &str, ) -> Result<(), GossipSubError>
Publish an inference request to all subscribers
Sourcepub fn publish_inference_result(
&self,
result_bytes: &[u8],
sender_peer_id: &str,
) -> Result<(), GossipSubError>
pub fn publish_inference_result( &self, result_bytes: &[u8], sender_peer_id: &str, ) -> Result<(), GossipSubError>
Publish an inference result to subscribers
Sourcepub fn announce_block(
&self,
cid: &str,
sender_peer_id: &str,
) -> Result<(), GossipSubError>
pub fn announce_block( &self, cid: &str, sender_peer_id: &str, ) -> Result<(), GossipSubError>
Publish a block availability announcement
Sourcepub fn publish_gradient_cid(
&self,
cid: &str,
sender_peer_id: &str,
) -> Result<(), GossipSubError>
pub fn publish_gradient_cid( &self, cid: &str, sender_peer_id: &str, ) -> Result<(), GossipSubError>
Publish a gradient CID to the GRADIENT_SYNC topic so that peers can fetch it.
The cid is the content-address of the Arrow IPC block holding the gradient tensor.
sender_peer_id is the local node’s peer-id string used as the message source.
Sourcepub fn announce_provider(
&self,
cid: &str,
peer_id: &str,
) -> Result<(), GossipSubError>
pub fn announce_provider( &self, cid: &str, peer_id: &str, ) -> Result<(), GossipSubError>
Publish a provider record announcement
Source§impl GossipSubManager
impl GossipSubManager
Sourcepub fn mesh_health(&self, topic: &TopicId) -> MeshHealthStatus
pub fn mesh_health(&self, topic: &TopicId) -> MeshHealthStatus
Return the aggregate mesh health status for a given topic.
Uses the manager’s configured mesh_n_low and mesh_n_high thresholds.
Sourcepub fn heal_mesh_if_needed(&self, topic: &TopicId) -> Vec<PeerId>
pub fn heal_mesh_if_needed(&self, topic: &TopicId) -> Vec<PeerId>
Attempt to heal the mesh for topic if it is underpeered.
Selects peers from the gossip peer score table that are not already in the mesh and grafts them in until D_low is satisfied. Returns the list of peer IDs grafted.
Sourcepub fn prune_mesh_if_needed(&self, topic: &TopicId) -> Vec<PeerId>
pub fn prune_mesh_if_needed(&self, topic: &TopicId) -> Vec<PeerId>
Prune the mesh for topic if it exceeds D_high.
Removes the lowest-scoring peers until the mesh size equals D_high. Returns the list of peer IDs pruned.
Auto Trait Implementations§
impl !RefUnwindSafe for GossipSubManager
impl !UnwindSafe for GossipSubManager
impl Freeze for GossipSubManager
impl Send for GossipSubManager
impl Sync for GossipSubManager
impl Unpin for GossipSubManager
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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