distributed_topic_tracker/gossip/
mod.rs1mod merge;
8mod receiver;
9mod sender;
10mod topic;
11
12pub use merge::{BubbleMerge, MessageOverlapMerge};
13pub use receiver::GossipReceiver;
14pub use sender::GossipSender;
15use serde::{Deserialize, Serialize};
16pub use topic::{Bootstrap, Publisher, Topic, TopicId};
17
18use crate::RecordPublisher;
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct GossipRecordContent {
26 pub active_peers: [[u8; 32]; 5],
28 pub last_message_hashes: [[u8; 32]; 5],
30}
31
32pub trait AutoDiscoveryGossip {
34 #[allow(async_fn_in_trait)]
39 async fn subscribe_and_join_with_auto_discovery(
40 &self,
41 record_publisher: RecordPublisher,
42 ) -> anyhow::Result<Topic>;
43
44 #[allow(async_fn_in_trait)]
48 async fn subscribe_and_join_with_auto_discovery_no_wait(
49 &self,
50 record_publisher: RecordPublisher,
51 ) -> anyhow::Result<Topic>;
52}
53
54impl AutoDiscoveryGossip for iroh_gossip::net::Gossip {
55 async fn subscribe_and_join_with_auto_discovery(
56 &self,
57 record_publisher: RecordPublisher,
58 ) -> anyhow::Result<Topic> {
59 Topic::new(record_publisher, self.clone(), false).await
60 }
61
62 async fn subscribe_and_join_with_auto_discovery_no_wait(
63 &self,
64 record_publisher: RecordPublisher,
65 ) -> anyhow::Result<Topic> {
66 Topic::new(record_publisher, self.clone(), true).await
67 }
68}