distributed_topic_tracker/gossip/
mod.rs1mod sender;
2mod receiver;
3mod topic;
4mod merge;
5
6pub use sender::GossipSender;
7pub use receiver::GossipReceiver;
8use serde::{Deserialize, Serialize};
9pub use topic::{Topic, TopicId, Publisher, Bootstrap};
10pub use merge::{BubbleMerge, MessageOverlapMerge};
11
12use crate::RecordPublisher;
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct GossipRecordContent {
16 pub active_peers: [[u8; 32]; 5],
17 pub last_message_hashes: [[u8; 32]; 5],
18}
19
20pub trait AutoDiscoveryGossip {
21 #[allow(async_fn_in_trait)]
22 async fn subscribe_and_join_with_auto_discovery(
23 &self,
24 record_publisher: RecordPublisher,
25 ) -> anyhow::Result<Topic>;
26
27 #[allow(async_fn_in_trait)]
28 async fn subscribe_and_join_with_auto_discovery_no_wait(
29 &self,
30 record_publisher: RecordPublisher,
31 ) -> anyhow::Result<Topic>;
32}
33
34impl AutoDiscoveryGossip for iroh_gossip::net::Gossip {
35 async fn subscribe_and_join_with_auto_discovery(
36 &self,
37 record_publisher: RecordPublisher,
38 ) -> anyhow::Result<Topic> {
39 Topic::new(
40 record_publisher,
41 self.clone(),
42 false,
43 )
44 .await
45 }
46
47 async fn subscribe_and_join_with_auto_discovery_no_wait(
48 &self,
49 record_publisher: RecordPublisher,
50 ) -> anyhow::Result<Topic> {
51 Topic::new(
52 record_publisher,
53 self.clone(),
54 true,
55 )
56 .await
57 }
58}